[RJS] How can i reload a script.

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&quot;&gt;&lt;/script&gt;&quot;

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\\&quot;&gt;&lt;/script&gt;&quot;\) } .........." But i can't see the effect in my page.

i don't know why it didn't work well. Thanks for your help.

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

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.

dear sender, i�m out of the office until may 29th. your email will not be forwarded. for urgent stuff please contact joern@fork.de kind regards, alexander