#7 enhancement
David Beckwith

Add onComplete for Ajax.PeriodicalUpdater

Reported by David Beckwith | April 14th, 2008 @ 06:49 AM | in 1.7


As far as i understand things, Ajax.PeriodicalUpdater's internal Ajax.Updater's callback onComplete has been overwritten by Ajax.PeriodicalUpdater#updateComplete, which prevents one from being able to customize the onComplete of the internal Ajax.Updater instance. I'm proposing a new option for Ajax.PeriodicalUpdater called onEachComplete, which, when set to a function, calls that function when the internal Ajax.Updater instance's onComplete callback is called. (phew what a mouthful.) The work around I have seen on the web is to use onSuccess, but that delays the calling of your custom function to the next call to Ajax.Updater.

I'm proposing to add 3 lines of code to the definition of Ajax.PeriodicalUpdater in prototype.js:

  updateComplete: function(response) {
	if (this.options.onEachComplete){

To use this cusomization, you would do something like this:

new Ajax.PeriodicalUpdater("current_box", "/boxes/1.json", {
  method: 'get',
  frequency : 5,
  decay : 1.1,
  onEachComplete: get_poll_data

This is my first attempted contribution, sorry for not following the protocol. I'm not sure exactly what to do. I'll post this to the google group as well.

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins