File-Upload Events and Dynamic page content
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.
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
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.
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
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 ?
SOLVED!
added the url option to the form and re initiated the file upload widget after form submit
Thanks for posting your solution. :)
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.
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