slippedangel
2007-May-23 13:18 UTC
PeriodicalUpdater.stop ignored if called from onSuccess
Hi, After hours of tweaking I''ve found that PeriodicalUpdater.stop() has no effect if called from the onSuccess function. Can someone tell me if this is intented and if it is what is the correct way of achieving the same thing. I have modified prototype.js by setting timer to -1 (and checking this in updateComplete) to make it work but would like a proper solution. My current code is: var ajax = null; function bodyOnLoad() { var url = ''log.php''; var params = ''address=<?php echo $_SERVER[''REMOTE_ADDR'']; ?>''; ajax = new Ajax.PeriodicalUpdater( {success: ''log''}, url, {method: ''get'', parameters: params, onFailure: reportError, onSuccess: success, frequency: 0.01, asynchronous: false} ); } function success(x) { if(opener.DBC && opener.DBC.complete) { document.getElementById(''done'').innerHTML document.getElementById(''done'').innerHTML + ''<br><input type="button" name="closeme" value="Close Log" onclick="javascript:window.close();">''; ajax.stop(); } setTimeout("scrollTo(0, document.body.clientHeight)", 1); } function reportError(request) { $F(''log'') = "Error"; } My prototype modification is: stop: function() { this.updater.options.onComplete = undefined; clearTimeout(this.timer); this.timer = -1; (this.onComplete || Prototype.emptyFunction).apply(this, arguments); }, updateComplete: function(request) { if (this.options.decay) { this.decay = (request.responseText == this.lastText ? this.decay * this.options.decay : 1); this.lastText = request.responseText; } if(this.timer != -1) { this.timer = setTimeout(this.onTimerEvent.bind(this), this.decay * this.frequency * 1000); } }, Thanks Gabriel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---