Hi,
I have a link_to_remote name ‘Show notes’, which calls an action that
uses this RJS template:
page.replace “notes_remote”, :partial => “notes/hide_notes_link”
page.insert_html :top, “notes_list”, :template => “notes/list”
page.visual_effect :highlight, ‘notes_list’, :duration => 3
Works great. The ‘Show notes’ link is replaced with a ‘Hide notes’
link, and a ‘notes_list’ div has some content displayed in it. The
highlight effect works as expected. Except…
The content that is displayed is, wait for it, the generated
javascript code: (!)
Element.replace(“notes_remote”, “Hide notes”); new
Insertion.Top(“notes_list”, null); new
Effect.Highlight(“notes_list”,{duration:3});
I went through Cody F.'s ‘add a fox’ tutorial[1], and it works
fine. Looking at the headers and content in Firebug, the only
difference I can see in the tutorial example is that the js code is
wrapped in a try/catch block.
Content-type is text/javascript, and I am including all the necessary
js files (as evidenced by the fact that the ajax bits “work”. I have
also done rake ‘update_javascripts’.
Fresh eyes appreciated.
jh
[1] http://www.codyfauser.com/articles/2005/11/20/rails-rjs-templates
–
James H.
Web application developer
Vancouver, BC
“Developing a coherent political analysis is in many respects
contingent upon an ability to connect one context to another, a
process not dissimilar to playing the kid’s game of dot-to-dot.”
- Ward Churchill, from ‘“A Government of Laws”?’