jQuery-File-Upload icon indicating copy to clipboard operation
jQuery-File-Upload copied to clipboard

File-Upload Events and Dynamic page content

Open gahula opened this issue 14 years ago • 8 comments

I am using handlebars for front end templating , which means dynamic page content of which my form is apart.

When page content is reloaded dynamically, this stops events from working that are associated with that changed content UNLESS the

$(document).on(events, selector, data, handler);

format is used. specifically the selector MUST BE provided. This means file-upload plugin will not recognise when files are added or othe event.

Where can I add the $(document).on(events, selector, data, handler) OR how can this be fixed.

gahula avatar Nov 10 '12 12:11 gahula

Please have a look here: https://github.com/blueimp/jQuery-File-Upload/wiki/Template-Engine

For further support questions, please post on the support forum: https://groups.google.com/d/forum/jquery-fileupload https://github.com/blueimp/jQuery-File-Upload#support

blueimp avatar Nov 10 '12 19:11 blueimp

Ok thanks, but Handlebars and other like it recreates the html fro dynamic content. However, if I wanted to change your event to use $(document).on(selector).... where can I find it in your code? was trying to track it down for some time. I believe it should be in the widget file.

gahula avatar Jan 19 '13 15:01 gahula

You can either reapply the file upload widget functionality to your changed content or catch input change or drag&drop events yourself and simply use the fileupload API functions.

If you want to modify the event handling behavior of the core plugin, you'll find the code here, in the * _initEventHandlers* method: https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.fileupload.js#L981

blueimp avatar Jan 20 '13 13:01 blueimp

So i looked at the events as you said and reapplied the file upload widget functionality to your changed content. The problem is being created because i have 2 declaration of the file-upload plugin. one for first load and one for form submission.

When i use either or it works. problem is how do i use only one given these two states

i.e. how would the URL remain defined throughout the form submission ?

gahula avatar Jan 22 '13 04:01 gahula

SOLVED!

added the url option to the form and re initiated the file upload widget after form submit

gahula avatar Jan 22 '13 07:01 gahula

Thanks for posting your solution. :)

blueimp avatar Jan 22 '13 09:01 blueimp

No problem... I would say add an attribute files-url to the input element and let that take precedence over the form action... I may desire two have to different urls for files and forms.. as I have.

OR

figure out why the URL option isn't being set after form is recreated.

gahula avatar Jan 25 '13 05:01 gahula

I add an upload="/files" to the form object...(I WILL TRY TO ET THIS TO WORK)

and changed your code to

line 437: options.url = options.fileInput.attr('upload') || options.form.prop('action') || location.href;

DID THIS SOLUTION... rather than replacing action in the form

gahula avatar Jan 25 '13 15:01 gahula