I met a problem about reloading a script. Below is the source code. display.rhtml: {{{ <%= text_field_tag :title %> <%= observe_field :title, :frequency => 0.5, :url => { :action => "update" }, :with => "title" %> <div id="preview"> <%= render :partial => "script", :object => @script %> </div> }}} _script.rhtml {{{ <%= @script %> }}} @script is a variable whose content is a javascript code, like "<script type="text/javascript" src="http://xxx?title=xxxx"></script>" preview_controller.rb: {{{ def update title = params[:title] @script = xxxxxx <- regenerate the script due to the title change. render :update do |page| page.replace "preview", :parital => "script", :object => @script end end }}} I can see the display of script at first. But when i change title, it just disappeared. I saw the response through firebug, which is like "try { Element.update("preview", "<script type=\"text/javascript\" src\"http://xxx?title=xxxx\"></script>") } .........." But i can''t see the effect in my page. i don''t know why it didn''t work well. Thanks for your help. --~--~---------~--~----~------------~-------~--~----~ 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, I guess that I have had success doing the following: a) edit the Javascript or RJS b) restart webserver or clear your cache It appears that the Javascript and/or RJS gets cached during server runs. Thus, I simply restart the server to clear the cache. This doesn''t happen all the time but restarting the server ensures that I''m running the latest code in my code base. Good luck, -Conrad On 5/23/07, sishen <YeDingding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I met a problem about reloading a script. > > Below is the source code. > > display.rhtml: > {{{ > <%= text_field_tag :title %> > <%= observe_field :title, :frequency => 0.5, :url => { :action => > "update" }, :with => "title" %> > > <div id="preview"> > <%= render :partial => "script", :object => @script %> > </div> > }}} > > _script.rhtml > {{{ > <%= @script %> > }}} > > @script is a variable whose content is a javascript code, like > "<script type="text/javascript" src="http://xxx?title=xxxx"></script>" > > preview_controller.rb: > {{{ > def update > title = params[:title] > @script = xxxxxx <- regenerate the script due to the title > change. > > render :update do |page| > page.replace "preview", :parital => "script", :object => > @script > end > end > }}} > > I can see the display of script at first. But when i change title, it > just disappeared. I saw the response through firebug, which is like > "try { Element.update("preview", "<script type=\"text/javascript\" src> \"http://xxx?title=xxxx\"></script>") } .........." But i can''t see > the effect in my page. > > i don''t know why it didn''t work well. Thanks for your help. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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. That''s not what i want. I want to give user a preview of the script result. And the result is changed when user input different title. So, i can''t restart webserver or clear the cache. On 5/24/07, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi, I guess that I have had success doing the following: > > a) edit the Javascript or RJS > b) restart webserver or clear your cache > > It appears that the Javascript and/or RJS gets cached during server > runs. Thus, I simply restart the server to clear the cache. This > doesn''t happen all the time but restarting the server ensures that I''m > running the latest code in my code base. > > Good luck, > > -Conrad > > On 5/23/07, sishen <YeDingding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I met a problem about reloading a script. > > > > Below is the source code. > > > > display.rhtml: > > {{{ > > <%= text_field_tag :title %> > > <%= observe_field :title, :frequency => 0.5, :url => { :action => > > "update" }, :with => "title" %> > > > > <div id="preview"> > > <%= render :partial => "script", :object => @script %> > > </div> > > }}} > > > > _script.rhtml > > {{{ > > <%= @script %> > > }}} > > > > @script is a variable whose content is a javascript code, like > > "<script type="text/javascript" src="http://xxx?title=xxxx"></script>" > > > > preview_controller.rb: > > {{{ > > def update > > title = params[:title] > > @script = xxxxxx <- regenerate the script due to the title > > change. > > > > render :update do |page| > > page.replace "preview", :parital => "script", :object => > > @script > > end > > end > > }}} > > > > I can see the display of script at first. But when i change title, it > > just disappeared. I saw the response through firebug, which is like > > "try { Element.update("preview", "<script type=\"text/javascript\" src> > \"http://xxx?title=xxxx\"></script>") } .........." But i can''t see > > the effect in my page. > > > > i don''t know why it didn''t work well. Thanks for your help. > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
alexander-0M91wEDH++c@public.gmane.org
2007-May-24 04:23 UTC
Re: [RJS] How can i reload a script.
dear sender, i´m out of the office until may 29th. your email will not be forwarded. for urgent stuff please contact joern-0M91wEDH++c@public.gmane.org kind regards, alexander --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---