I''m trying to set up a nested menu strucutre using RJS I want to be click on an item, have not have the whole page refresh but just have the menu <li id=''Selection''> refreshed 1 - my model is using :acts_as_tree 2 - in my controller I have the following.. it''s just a barebones start at being able to dig DOWN through the chilren def renderMenu render :update do |page| page.replace_html "Selection", :partial => ''selection'', :collection => Program.find(params[:id]).children end end 3- my :partial => ''selection'' is the following "_selection.rhtml" file <li><%= link_to_remote selection.name, :update => "Selection", :url => {:action => :renderMenu, :id => selection.id} %> </li> 4- my layout provides the following strucutre: <div> <ul id="Selection"> <%= render :partial => ''selection'', :collection => @menu[:BreadCrumb][-1].children %> </ul> </div> -------anyways :) so this is hte problem i''m having: it sort of works but I think i''m getting a prototype error...when I click on a parent element to see its children, I get a mix of what I want and an error message..all mixed up try { Element.update("Selection", " <half the children displayed properly> "); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''Element.update(\"Selection\", \" <second half of the children> \");''); throw e } any suggestions? -- Posted via http://www.ruby-forum.com/.
Andrew Gibson wrote:> try { Element.update("Selection", " > <half the children displayed properly> > "); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); > alert(''Element.update(\"Selection\", \" > <second half of the children> > \");''); throw e }That try/catch stuff is just there for RJS debugging. So that when some javascript error occurrs you will get an alert with the details of the error. But is the javascript actually executing? or is it just showing up on the page as text? If it''s showing up as text you need to set: @headers[''Content-Type''] = ''text/javascript'' Although if you use "render :update" that should be done for you. Get the Firebug extension for Firefox so you can examine the headers and content of the response to your ajax calls. It should help you figure out whats going on. -- Posted via http://www.ruby-forum.com/.
the javascript is executing..the child elements are apeparing..but they''re being around by the javascript error handling output Alex Wayne wrote:> Andrew Gibson wrote: >> try { Element.update("Selection", " >> <half the children displayed properly> >> "); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); >> alert(''Element.update(\"Selection\", \" >> <second half of the children> >> \");''); throw e } > > That try/catch stuff is just there for RJS debugging. So that when some > javascript error occurrs you will get an alert with the details of the > error. > > But is the javascript actually executing? or is it just showing up on > the page as text? If it''s showing up as text you need to set: > > @headers[''Content-Type''] = ''text/javascript'' > > Although if you use "render :update" that should be done for you. Get > the Firebug extension for Firefox so you can examine the headers and > content of the response to your ajax calls. It should help you figure > out whats going on.-- Posted via http://www.ruby-forum.com/.
a couple of things. First you''re not just updating the <li>, you''re updating the whole ordered lists. In your partial you don''t need the :update symbol in there. Finally, like the other poster said, get Firebug. Turn on the Options >> ShowXHTMLRequests. View your Console and look at the Request as well as the Response. I suspect you''ll find the problem. Michael
AAAAh.... thanks :) the :update did the trick Michael Trier wrote:> a couple of things. First you''re not just updating the <li>, you''re > updating the whole ordered lists. In your partial you don''t need the > :update symbol in there. Finally, like the other poster said, get > Firebug. Turn on the Options >> ShowXHTMLRequests. View your Console > and look at the Request as well as the Response. I suspect you''ll > find the problem. > > Michael-- Posted via http://www.ruby-forum.com/.