[uploader] Using uploader from AJAX requests [5.2.1-RC1]
In - INP-1253Getting issue details... STATUS we've corrected uploader code, so initialization would happen without problems inside modal windows (DIVs produced from AJAX requests, like ThickBox, ColorBox, etc.). However we're not accounting for cases, when same modal window (which has uploader inside) would be opened twice (or more) without doing page refresh.
In such case we have 2 problems:
- previous uploader objects (that were created when modal window was opened before) are not removed
- if attempt is made to remove uploader (via
UploadsManager.RemoveUploader(uploader_id)
method), then it's initialization hooks are not removed
I don't know how to solve 1st problem, because we need 100% bullet-proof way of detecting uploader origin (page itself or a modal window). However I have a solution for 2nd problem.
if ( this.params.ajax ) { $(document).bind('FormManager.WindowManager.Ready', function ($e) { $me.init(); }); } else { $(document).ready(function() { $me.init(); }); }
In above listed code we need to replace bind
with one
, to automatically remove event listener once it's being invoked.