Upload form now shows an image button and submits automatically.
This commit is contained in:
parent
c691f60ef1
commit
94de7fc9ca
1 changed files with 18 additions and 8 deletions
|
|
@ -26,15 +26,9 @@
|
|||
|
||||
// Upload image
|
||||
li
|
||||
/ = form_tag(upload_image_path, multipart: true)
|
||||
/ = file_field_tag('image')
|
||||
/ = submit_tag
|
||||
|
||||
= form_for :screenshot, url: upload_image_path, html: { multipart: true } do |f|
|
||||
= f.label :image, 'Upload new screenshot'
|
||||
= f.file_field :image, id: 'fileupload', multiple: true
|
||||
= f.submit "Upload"
|
||||
//- raise
|
||||
= image_tag("/images/dummy/upload.svg", style: "width: 100%", id: 'upload-image')
|
||||
= f.file_field :image, id: 'fileupload', multiple: true, style: 'display: none'
|
||||
|
||||
// TODO: Enable comments in a later version
|
||||
// = partial '/package/comments'
|
||||
|
|
@ -73,3 +67,19 @@
|
|||
// //$('#comment-content,#comment-author').fadeIn();
|
||||
// $('form.comment > *').fadeIn();
|
||||
// });
|
||||
|
||||
javascript:
|
||||
$(function () {
|
||||
// If the image button is clicked then imitate a click on the file
|
||||
// select button that is hidden.
|
||||
$("#upload-image").click( function () {
|
||||
$("#fileupload").click();
|
||||
});
|
||||
|
||||
// Files have been selected. Tell the user what's going on and
|
||||
// submit the upload form.
|
||||
$('#fileupload').change( function () {
|
||||
$('#upload-image').attr('src', '/images/dummy/please-wait.svg');
|
||||
$('form').submit();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue