Here's a way to combine PeriodicalExecuter's duplicate protection into
Form.Element.Observer, and add the ability to stop the observer during
form validation or while waiting for AJAX requests to complete, and
restart it afterwards:
Object.extend(Form.Element.Observer.prototype, {
registerCallback: function() {
this.pe = new PeriodicalExecuter(this.onTimerEvent.bind(this),
this.frequency);
},
stop: function() {
if (this.pe) this.pe.stop();
},
start: function() {
this.lastValue = this.getValue();
this.registerCallback();
}
});
The start method is really "restart" because it resets the lastValue.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---