This is driving me nuts:-) I''ve brought it down to a simplified case where I''m rendering this rjs template: page.insert_html :top, ''cat1'', "<li>Some list item</li>" According to FireBug, this is what I''m actually getting in the browser: try { new Insertion.Top("cat1", "<li>Some list item</li>"); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new Insertion.Top(\"cat1\", \"<li>Some list item</li>\");''); throw e } This all looks right to me, though I''m no Javascript expert. The headers have Content-Type: text/javascript. But what is actually being displayed instead of a new list item is something like: try { new Insertion.Top("cat1", " o Some list item "); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new Insertion.Top(\"cat1\", \" o Some list item \");''); throw e } (...where the o''s represent the little list-item dots -- the two instances of "Some list item" are actually being displayed as list items). Can anybody throw a clue to a clueless man? Thanks in advance! --Al Evans -- Posted via http://www.ruby-forum.com/.
If you are using :update => ''someid'' in your link_to_remote this will happen. See if that''s the cause. -- View this message in context: http://www.nabble.com/RJS----What-am-I-missing--tf1858282.html#a5075103 Sent from the RubyOnRails Users forum at Nabble.com.
I recently ran into this, though it''s an easy fix. Whatever the remote call is (link_to_remote, form_remote_tag, etc) have a first parameter of which DOM element to update. The RJS returns the javascript string, so the Ajax call promplty updates that element with the new text. However, RJS want''s to update elements itself. So just give the remote link a blank string where it asks for an element to update, e.g.: link_to_remote '''', url_stuff Jason Al Evans wrote:> This is driving me nuts:-) > > I''ve brought it down to a simplified case where I''m rendering this rjs > template: > > page.insert_html :top, ''cat1'', "<li>Some list item</li>" > > According to FireBug, this is what I''m actually getting in the browser: > > try { > new Insertion.Top("cat1", "<li>Some list item</li>"); > } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new > Insertion.Top(\"cat1\", \"<li>Some list item</li>\");''); throw e } > > This all looks right to me, though I''m no Javascript expert. The headers > have > Content-Type: text/javascript. > > But what is actually being displayed instead of a new list item is > something like: > > try { new Insertion.Top("cat1", " > o Some list item > "); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new > Insertion.Top(\"cat1\", \" > o Some list item > \");''); throw e } > > (...where the o''s represent the little list-item dots -- the two > instances of "Some list item" are actually being displayed as list > items). > > Can anybody throw a clue to a clueless man? > > Thanks in advance! > > --Al Evans > >
Al Evans wrote:> This is driving me nuts:-) > > I''ve brought it down to a simplified case where I''m rendering this rjs > template: > > page.insert_html :top, ''cat1'', "<li>Some list item</li>" > > According to FireBug, this is what I''m actually getting in the browser: > > try { > new Insertion.Top("cat1", "<li>Some list item</li>"); > } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new > Insertion.Top(\"cat1\", \"<li>Some list item</li>\");''); throw e } > > This all looks right to me, though I''m no Javascript expert. The headers > have > Content-Type: text/javascript. > > But what is actually being displayed instead of a new list item is > something like: > > try { new Insertion.Top("cat1", " > o Some list item > "); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new > Insertion.Top(\"cat1\", \" > o Some list item > \");''); throw e } > > (...where the o''s represent the little list-item dots -- the two > instances of "Some list item" are actually being displayed as list > items). > > Can anybody throw a clue to a clueless man? > > Thanks in advance! > > --Al Evans > >What does your controller look like for the involved actions? Are you doing a remote call (what you should be doing) or are you just doing a normal action call? It sounds like your rjs is correct but your controller is not rendering what you want. Matthew Margolis blog.mattmargolis.net
Al Evans wrote:> This is driving me nuts:-) > > I''ve brought it down to a simplified case where I''m rendering this rjs > template: > > page.insert_html :top, ''cat1'', "<li>Some list item</li>"> But what is actually being displayed instead of a new list item is > something like: > > try { new Insertion.Top("cat1", " > o Some list item > "); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new > Insertion.Top(\"cat1\", \" > o Some list item > \");''); throw e } > > --Al EvansRemove the :update portion of your link_to_remote tag. :update says "shove whatever the result is into the element with id=''foo''". You just want the javascript to execute, so take out the :update and let it do its thang. -- Posted via http://www.ruby-forum.com/.
Alex Wayne wrote:> Remove the :update portion of your link_to_remote tag. :update says > "shove whatever the result is into the element with id=''foo''". You just > want the javascript to execute, so take out the :update and let it do > its thang.Thanks! That was the problem. I knew it had to be something simple. Stupid newbie tricks.... :-) --Al Evans -- Posted via http://www.ruby-forum.com/.