I used RJS extensively in my last web app with no problem. I''m just beginning a new one and having a very odd problem. The called method, get_names, retrieves some values from the database, then ends: render :layout => false the get_names.rjs file is rendered into Javascript, but then is just dumped as Javascript (text) into the browser: e.g: try { Element.update("this_panel", ""); new Insertion.Bottom( ... ); } catch (e) { alert(''RJS error:\n\n'' Any ideas? Thanks! -- Posted via http://www.ruby-forum.com/.
Does the link_to_remote by any chance have an :update => ''this_panel'' in it ? That would take the reuslt of the Ajax call and update the div. I often make this mistake if I start with an update and replace it with RJS. Alan Chris Hackel wrote:> the get_names.rjs file is rendered into Javascript, but then is just > dumped as Javascript (text) into the browser:-- Posted via http://www.ruby-forum.com/.
Alan Francis wrote:> Does the link_to_remote by any chance have an :update => ''this_panel'' in > it ? That would take the reuslt of the Ajax call and update the div. > I often make this mistake if I start with an update and replace it with > RJS. > > Alan > > Chris Hackel wrote: > >> the get_names.rjs file is rendered into Javascript, but then is just >> dumped as Javascript (text) into the browser:Alan--no it''s just this: <%= form_remote_tag :url => { :controller => "name", :action => "get_name"} %> <label for="name_input">Enter your name:</label> <%= text_field "name_input","name", :size => 20 %> <%= end_form_tag %> -- Posted via http://www.ruby-forum.com/.
Chris Hackel wrote:> Alan Francis wrote: > >> Does the link_to_remote by any chance have an :update => ''this_panel'' in >> it ? That would take the reuslt of the Ajax call and update the div. >> I often make this mistake if I start with an update and replace it with >> RJS. >> >> Alan >> >> Chris Hackel wrote: >> >> >>> the get_names.rjs file is rendered into Javascript, but then is just >>> dumped as Javascript (text) into the browser: >>> > > > Alan--no it''s just this: > > <%= form_remote_tag :url => { :controller => "name", :action => > "get_name"} %> > <label for="name_input">Enter your name:</label> > <%= text_field "name_input","name", :size => 20 %> > <%= end_form_tag %> > >Can you paste your .rjs file? Like Alan I have seen this before when setting :update but since you are not doing that the problem may be in the rjs. Matthew Margolis blog.mattmargolis.net
> Can you paste your .rjs file? Like Alan I have seen this before when > setting :update but since you are not doing that the problem may be in > the rjs.One other problem might be content type. If you copy the code from the rjs into the action and use render :update instead, does it work there ? http://codefluency.com/articles/2006/05/27/rails-views-render-update-not-rjs/ A. -- Posted via http://www.ruby-forum.com/.
Alan Francis wrote:>> Can you paste your .rjs file? Like Alan I have seen this before when >> setting :update but since you are not doing that the problem may be in >> the rjs. > > One other problem might be content type. If you copy the code from the > rjs into the action and use render :update instead, does it work there ? > > http://codefluency.com/articles/2006/05/27/rails-views-render-update-not-rjs/ > > A.Also, did you remember to add the javascript tags to the layout ? A. -- Posted via http://www.ruby-forum.com/.