Hello All, I''ve seen this topic but it seems no one has post a response. I''m using periodicalUpdater to display live content queried from a database. Sometimes the result can be thousands of rows and before it finishes processing (displaying as a visual indicator) all the data, the next request is sent to the server. I''d like to have a periodicalUpdater whose frequency can be set bases on the size of the result set. I''ve tried to set onSuccess: function() { this.frequency = dataSize * 5; } While this does change this.frequency, but when I tried to alert(this.frequency) in subsequent onCreate callback, it remains the value the PU is initialized with. (and the PU updates according to the initial frequency). Is there a way to change frequency in the exposed onSuccess or onCreate call back? Or how can I pass the dataSize to the updateComplete in prototype.js, if that''s the way to go? Thanks for your time. Debbie --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Polgardy
2008-Jun-13 19:03 UTC
Re: dynamically change frequency in periodicalUpdater
Just changing the frequency property wouldn''t cause the refresh rate to change. It''s set up with a setInterval() call which is implemented in the browser. I''d either monkey patch PeriodicalUpdater to do a clearInterval() followed by setInterval() with the new value, or just shut down the PU and start up a new one. -Fred On Fri, Jun 13, 2008 at 12:51 PM, Debbie <liu9471-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello All, > > I''ve seen this topic but it seems no one has post a response. I''m > using periodicalUpdater to display live content queried from a > database. Sometimes the result can be thousands of rows and before it > finishes processing (displaying as a visual indicator) all the data, > the next request is sent to the server. I''d like to have a > periodicalUpdater whose frequency can be set bases on the size of the > result set. I''ve tried to set-- 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 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 -~----------~----~----~----~------~----~------~--~---
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; } --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Polgardy
2008-Jun-25 17:57 UTC
Re: dynamically change frequency in periodicalUpdater
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 <liu9471-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 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 -~----------~----~----~----~------~----~------~--~---
Possibly Parallel Threads
- RE: Prototype: correct useage of onComplete withAjax.PeriodicalUpdater
- RE: Prototype: correct useage of onCompletewithAjax.PeriodicalUpdater
- Does Ajax.PeriodicalUpdater have a shield against multiple parallel executions?
- PeriodicalUpdater onComplete broken?
- Prototype: correct useage of onComplete with Ajax.PeriodicalUpdater