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
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
-~----------~----~----~----~------~----~------~--~---