Hmm, I'm not quite sure how this works. :)  You appear to be referring to
two different updaters (updater and this.updater), but they actually refer
to the same object because the function is unbound, and updater is a global.

And sadly, I was wrong the whole time, PeriodicalUpdater doesn't use a
setInterval(), but a delayed function call.  You can change the frequency
value at any time by calling updater.frequency = newValue.

Sorry for the wild goose chase, but you learned something right? ;-)  (Like,
don't trust people who post to mailing lists?)

-Fred

On Wed, Jun 25, 2008 at 12:28 PM, Debbie <[EMAIL PROTECTED]> wrote:

>
> Thanks Fred.
>
> I've followed the second option and it worked.  Below is my code, in
> case someone will find it helpful:
>
> var updateCounter = 0;
> function createUpdater(freq)
> {
>    updater = new Ajax.PeriodicalUpdater("ajaxDIV", "Tickets.jsp", {
>        frequency: freq,
>        evalScripts: true,
>        onCreate: function()
>        {
>                // change update frequency when data size changes, and
> after the initial load
>            if (updateCounter != 0 && dataSize != this.frequency / 5)
>            {
>                alert("data size changed. frequency new: " + dataSize
> * 5 + " old: " + this.frequency)
>                updateCounter = 0;
>                updater = createUpdater(dataSize * 5);
>                this.updater.stop();
>            }
>        },
>        onSuccess: function()
>        {
>            updateCounter ++;
>        },
>        parameters: Form.serialize($("form"))
>    }
>            )
>            ;
>    return updater;
> }


-- 
Science answers questions; philosophy questions answers.

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

Reply via email to