Forum: Ruby on Rails [RJS] How can i reload a script.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
sishen (Guest)
on 2007-05-24 07:30
(Received via mailing list)
I met a problem about reloading a script.

Below is the source code.

<%= text_field_tag :title %>
<%= observe_field :title, :frequency => 0.5, :url => { :action =>
"update" }, :with => "title" %>

<div id="preview">
   <%= render :partial => "script", :object => @script %>

<%= @script %>

@script is a variable whose content is a javascript code, like
"<script type="text/javascript" src="http://xxx?title=xxxx"></script>"

def update
    title = params[:title]
    @script = xxxxxx   <-  regenerate the script due to the title

    render :update do |page|
       page.replace "preview", :parital => "script", :object =>

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.
Conrad T. (Guest)
on 2007-05-24 08:02
(Received via mailing list)
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,

sishen (Guest)
on 2007-05-24 08:22
(Received via mailing list)
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.
unknown (Guest)
on 2007-05-24 08:23
(Received via mailing list)
dear sender,
i´m out of the office until may 29th.
your email will not be forwarded.
for urgent stuff please contact removed_email_address@domain.invalid
kind regards,
This topic is locked and can not be replied to.