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 Fauser''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 Hughes 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"?''
James Hughes wrote:> The content that is displayed is, wait for it, the generated > javascript code: (!)Make sure you are not using the :update option in the link_to_remote. The :update takes whatever is returned by the server and sticks it in the specified DOM id. SO it''s used when the server returns HTML. When the server returns javascript, in the case of RJS, it should simply be executed, and the javascript itself decides what gets manipulated. In case I am wrong, post you link_to_remote call cause that might be where the problem is. -- Posted via http://www.ruby-forum.com/.
James Hughes
2006-Jun-08 18:36 UTC
[Rails] Re: RJS wierdness - Content div display js code
On 6/8/06, Alex Wayne <rubyonrails@beautifulpixel.com> wrote:> James Hughes wrote: > > The content that is displayed is, wait for it, the generated > > javascript code: (!) > > Make sure you are not using the :update option in the link_to_remote. > The :update takes whatever is returned by the server and sticks it in > the specified DOM id. SO it''s used when the server returns HTML. When > the server returns javascript, in the case of RJS, it should simply be > executed, and the javascript itself decides what gets manipulated. > > In case I am wrong, post you link_to_remote call cause that might be > where the problem is.Alex, thanks so much, that was exactly the problem. Now to figure out why the options_for_render param to insert_html is generating null. jh -- James Hughes 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"?''
Alex Wayne
2006-Jun-08 19:13 UTC
[Rails] Re: Re: RJS wierdness - Content div display js code
James Hughes wrote:> Alex, thanks so much, that was exactly the problem. > > Now to figure out why the options_for_render param to insert_html is > generating null.because :template is not a valid option? I think you have to use partial. -- Posted via http://www.ruby-forum.com/.