Hi All,

I am making some testing (maybe I will post something later) and I
found out that the stop() of the Ajax.PeriodicalUpdater does not work
as I expected.
Looking to the code I can see that :

  stop: function() {
    this.updater.onComplete = undefined;
    clearTimeout(this.timer);
    (this.onComplete || Prototype.emptyFunction).apply(this,
arguments);
  },

After clearing timeout, we call again Prototype.emptyFunction which
will continue calling by reseting the timer again into the
updateComplete().

I solved this by introducing a variable mustStop in constructor that is
initialized to false,
then :

  stop: function() {
    this.updater.onComplete = undefined;
    clearTimeout(this.timer);
    this.mustStop = true;                  <------ added
    (this.onComplete || Prototype.emptyFunction).apply(this,
arguments);
  },

and eventually :

  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.mustStop)              <----- condition added
        this.timer = setTimeout(this.onTimerEvent.bind(this),
                                            this.decay * this.frequency
* 1000);
  },

Actually I am not sure I was using it right or if I miss something when
using this PeriodicalUpdate.
I create this object and after I just call stop, but it does not ..so
maybe there is a parameter missing somewhere ?

Thanks
Franck


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---

Reply via email to