kartik-v / bootstrap-fileinput

An enhanced HTML 5 file input for Bootstrap 5.x/4.x./3.x with file preview, multiple selection, and more features.
http://plugins.krajee.com/file-input
Other
5.36k stars 2.4k forks source link

Looping fileunlock event when using AJAX #110

Closed zebub closed 9 years ago

zebub commented 9 years ago

I'm experiencing strange behavior when performing an AJAX request in a fileunlock event.

$('#upload').on('fileunlock', function (event, filestack, extraData) {
    $.ajax();
});

This causes the fileunlock event to trigger when the AJAX request completes, in turn causing a loop.

kartik-v commented 9 years ago

This is because the unlock method is called within ajaxStop... and if you trigger another ajax inside unlock, its calling itself on ajaxStop.

If you upgrade to the latest release, the plugin uses some flags to check the locked status before triggering unlock. So you should not face this.

For advanced usage and your info.. the updated plugin also uses namespaces to bind ajaxStop (i.e. ajaxStop.kvfileinput instead of ajaxStop - so one can unbind the .kvfileinput for advanced ajax calls).