I have set up a periodically call remote on a page. To get it to stop calling I have made it reliant on a hidden element being populated with some value, this is all working. But I want to actually delete the script from the DOM based on a decision from the server. What would be the best way to go about doing this? Thanks Regards Mikel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
that should be possible with rjs, shouldnt it? like that in the controller: page[''updater''].replace '''' <div id="updater"><%= rails updater helper %></div> On 24 Jun., 13:51, Mikel <raasd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have set up a periodically call remote on a page. To get it to stop > calling I have made it reliant on a hidden element being populated > with some value, this is all working. > > But I want to actually delete the script from the DOM based on a > decision from the server. > > What would be the best way to go about doing this? > > Thanks > > Regards > > Mikel--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Mikel, Mikel wrote:> I have set up a periodically call remote on a page. To get it to stop > calling I have made it reliant on a hidden element being populated > with some value, this is all working. > > But I want to actually delete the script from the DOM based on a > decision from the server. > > What would be the best way to go about doing this?One way to handle it would be to wrap the periodically_call_remote with a <div id="unique_id> and use RJS. Either page.replace or page.replace_html depending on whether you wanted to get rid of the div entirely or just some of what''s inside. hth, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Mikel wrote: > >> I have set up a periodically call remote on a page. To get it to stop >> calling I have made it reliant on a hidden element being populated >> with some value, this is all working. >> >> But I want to actually delete the script from the DOM based on a >> decision from the server. >> >> What would be the best way to go about doing this? > > One way to handle it would be to wrap the periodically_call_remote with a > <div id="unique_id> and use RJS. Either page.replace or page.replace_html > depending on whether you wanted to get rid of the div entirely or just > some > of what''s inside.That won''t work because DIV only launches the JavaScript object. This persists in memory for ever and ever. The fix is to use :condition to detect a JS variable, and then use another Ajax update to set this to false. Start with this JS: keep_polling = true; ... <%= periodically_call_remote( :url => {:action => ''slow_thing'' }, :frequency => 5, :condition => ''keep_polling == true'' ) %> When the slow_thing finishes, it can use render :update to send ''keep_polling = false''. -- Phlip http://www.oreilly.com/catalog/9780596510657/ "Test Driven Ajax (on Rails)" assert_xpath, assert_javascript, & assert_ajax --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mikel wrote:> I have set up a periodically call remote on a page. To get it to stop > calling I have made it reliant on a hidden element being populated > with some value, this is all working. > > But I want to actually delete the script from the DOM based on a > decision from the server. > > What would be the best way to go about doing this?I answered this a couple days ago. Use Google Groups and look for periodically_call_remote and my street name. -- Phlip http://www.oreilly.com/catalog/9780596510657/ "Test Driven Ajax (on Rails)" assert_xpath, assert_javascript, & assert_ajax --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, Regards Mikel On Jul 1, 12:53 pm, "Phlip" <phlip2...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Mikel wrote: > > I have set up a periodically call remote on a page. To get it to stop > > calling I have made it reliant on a hidden element being populated > > with some value, this is all working. > > > But I want to actually delete the script from the DOM based on a > > decision from the server. > > > What would be the best way to go about doing this? > > I answered this a couple days ago. Use Google Groups and look for > periodically_call_remote and my street name. > > -- > Phlip > http://www.oreilly.com/catalog/9780596510657/ > "Test Driven Ajax (on Rails)" > assert_xpath, assert_javascript, & assert_ajax--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---