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” %>
_script.rhtml
{{{
<%= @script %>
}}}
@script is a variable whose content is a javascript code, like
“”
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.