#jQuery fileupload for dynamically added input field
@admin
Updated September 2, 2015 ● 7,860 views
Updated September 2, 2015 ● 7,860 views
Programming
jQuery fileupload from Blueimp is one of the good file upload jQuery Ajax classes. I used this class in the development of this website.
To make it work for dynamically added input field use the jQuery live() function. This attach an event handler for all elements which match the current selector, now and in the future.
Example:
$('#fileupload').live('click', function(e) { $('#fileupload').fileupload({ url: '', type:'post',dataType: 'json',autoUpload: false, formData: {}, add: function(e, data, textStatus){ .success(function (result, textStatus, jqXHR) {}) .error(function (jqXHR, textStatus, errorThrown) {}) .complete(function (result, textStatus, jqXHR) {}); }, progress: function (e, data, jqXHR) { }, done: function (e, data) { }, }) });
3 Comments
Related
▶︎
More in Programming
▶︎
Thank you so much. I have spent a lot of time trying to get the fileupload to work with dynamic vars until I found this post.
cami · 10 years agopermalink · reply (0)
Fantastic! Thank you very much!
Prakash1 · 11 years agopermalink · reply (0)
Thanks for this tip! I've been wondering why the hell the jQuery fileupload wasn't working.
Ronn · 11 years agopermalink · reply (0)