i have a periodical updater running. i want to send a different Ajax.Updater if the periodical updater''s information changed. what''s the best way to do this? i know the periodical updater knows if the content has changed, this is how it would know if the decay needs to activate or not. can i use that to my advantage in determining whether another function, containing an Updater would execute? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jan 21, 2008 7:00 PM, ahs10 <quietawake-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > i want to send a different > Ajax.Updater if the periodical updater''s information changed.What do you mean by this? A different URL? Different parameters? You might be able to accomplish what you need by passing in an onComplete method to invoke, or if that doesn''t work out you can always override/wrap the updateComplete method to do what you need. -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
sorry, let me try to explain it better... i have a periodical updater running, i want to run a javascript function when the response for the periodical updater has changed. i still want the periodical updater to keep running, and i want the function to run each time the response is different from the last response. i don''t know if that makes any more sense, so i''ll try to sketch out what i''d like.... var prevResponse=transport.responseText new Ajax.PeriodicalUpdater(''dynaDiv'', ''php/myScript.php'', {method: ''post'', frequency: 5}, onSuccess: function(transport) { if (prevResponse != transport.responseText) { myFunction(); }; }); function myFunction() { new Ajax.Request(destination, { method: ''post'', parameters: {whatever: whatever}, onSuccess: function(transport) { var response = transport.responseText || "No response text"; document.getElemenetById(''dynaDiv2'').innerHTML=response; }); } On Jan 21, 9:15 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 21, 2008 7:00 PM, ahs10 <quietaw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > i want to send a different > > Ajax.Updater if the periodical updater''s information changed. > > What do you mean by this? A different URL? Different parameters? > > You might be able to accomplish what you need by passing in an > onComplete method to invoke, or if that doesn''t work out you can > always override/wrap the updateComplete method to do what you need. > > -justin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jan 22, 2008 11:58 AM, ahs10 <quietawake-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i have a periodical updater running, i want to run a javascript > function when the response for the periodical updater has changed. i > still want the periodical updater to keep running, and i want the > function to run each time the response is different from the last > response.Your code mostly looks OK except that maybe you should just call a function and pass in the current request object and let it deal with all the logic of determining if the response has changed or not. Something like: var Handler = { lastResponse:null, success: function(xhrRequest){ if (this.lastResponse && xhrRequest.transport.responseText !this.lastResponse){ // the response has changed } this.lastResponse = xhrRequest.transport.responseText; } }; new Ajax. PeriodicalUpdater(''div-id'', ''/your/url'', { onComplete: function(response){ Handler.lastResponse(response); } }); I''m not saying this is the best way to accomplish this, but based on a brief test it does seem to function how you''d like it to. -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I see what he is saying though, it''d be nice to have a "change" event in the PU. But Justin solution certainly does the trick. On Jan 22, 3:22 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 22, 2008 11:58 AM, ahs10 <quietaw...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > i have a periodical updater running, i want to run a javascript > > function when the response for the periodical updater has changed. i > > still want the periodical updater to keep running, and i want the > > function to run each time the response is different from the last > > response. > > Your code mostly looks OK except that maybe you should just call a > function and pass in the current request object and let it deal with > all the logic of determining if the response has changed or not. > Something like: > > var Handler = { > lastResponse:null, > success: function(xhrRequest){ > if (this.lastResponse && xhrRequest.transport.responseText !> this.lastResponse){ > // the response has changed > } > this.lastResponse = xhrRequest.transport.responseText; > } > > }; > > new Ajax. PeriodicalUpdater(''div-id'', ''/your/url'', { onComplete: > function(response){ Handler.lastResponse(response); } }); > > I''m not saying this is the best way to accomplish this, but based on a > brief test it does seem to function how you''d like it to. > > -justin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---