Open imbibinebe opened 9 years ago
these are internal handlers
https://github.com/mootools/mootools-core/blob/master/Source/Request/Request.js#L106-L116
I would probably prefer to have the this.fireEvent('complete')
independent, preceding this line:
https://github.com/mootools/mootools-core/blob/master/Source/Request/Request.js#L82
On 25 August 2015 at 22:08, Tin LE GALL notifications@github.com wrote:
Hi there I develop a mobile app with a controller > view architecture combined with asynchronous AJAX requests. In order to avoid memory leaks, in destroy current controller and view (DOM) when the user switch back to a previous view ([back] button ...) My onSuccess method uses to update the view depending on data retrieved from the AJAX call and that's why I don't want it to be executed if the user left this view cause it's not surprisingly generating javascript errors ... tests I have to do are always the same and that's why i didn't want to put them in each of my onSuccess methods (many) since I have an onComplete method which is common to all my requests. Then here is what I do:
onComplete: function(e) { if(my tests are not OK) { this.removeEvents().setOptions({timeout:0}).cancel(); return; } ... few other things if tests are OK ... }
This is working correctly (onSuccess method is not executed) if the user switch back fast enough on the previous view ([back] button) but not if he waits to long (like 0.5 or 1s more). Here is what is see in mootools-core source code.
onSuccess: function(){ this.fireEvent('complete', arguments).fireEvent('success', arguments).callChain(); },
I thought that onSuccess method were executed only when onComplete method has finished. Isn't it the case ? Do you have an idea of how I should do ?
Best
— Reply to this email directly or view it on GitHub https://github.com/mootools/mootools-core/issues/2730.
Dimitar Christoff
"JavaScript is to JAVA what hamster is to ham" @D_mitar - https://github.com/DimitarChristoff
Hi there I develop a mobile app with a controller > view architecture combined with asynchronous AJAX requests. In order to avoid memory leaks, in destroy current controller and view (DOM) when the user switch back to a previous view ([back] button ...) My onSuccess method uses to update the view depending on data retrieved from the AJAX call and that's why I don't want it to be executed if the user left this view cause it's not surprisingly generating javascript errors ... tests I have to do are always the same and that's why i didn't want to put them in each of my onSuccess methods (many) since I have an onComplete method which is common to all my requests. Then here is what I do:
This is working correctly (onSuccess method is not executed) if the user switch back fast enough on the previous view ([back] button) but not if he waits to long (like 0.5 or 1s more). Here is what is see in mootools-core source code.
I thought that onSuccess method were executed only when onComplete method has finished. Isn't it the case ? Do you have an idea of how I should do ?
Best
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.