Hi, I''ve got a js object on my page named appts which has a method render(). My problem is when i use RJS to call "appts.render()". it doesn''t do anything at all. There are no errors also displayed. here is my rjs code: page << "appts.render(''BG'',0);" help would be much appreciated:) thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 19 October 2006 12:24, franee -- wrote:> I''ve got a js object on my page named appts which has a method render(). > My problem is when i use RJS to call "appts.render()". it doesn''t do > anything at all. There are no errors also displayed. > > here is my rjs code: > > page << "appts.render(''BG'',0);"Here is the problem resolution sequence: 1. Turn on browser''s javascript debugging (e.g. in Firefox take a look at javascript console or install a powerful FireBug extension). You''ll see all the javascript errors. 2. Examine javascript code that is generated by RJS template. Make sure that it contains no errors (you can view RJS response in FireBug''s console). 3. Make sure that the RJS response is properly evaled. E.g. in Ajax.Request there should be evalScripts options set to true. 4. Make sure that you don''t overwrite RJS response''s content type and it is equal to "text/javascript" (you can view RJS response in FireBug''s console). Hope that helps --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Maxim Kulkin wrote:> On 19 October 2006 12:24, franee -- wrote: >> I''ve got a js object on my page named appts which has a method render(). >> My problem is when i use RJS to call "appts.render()". it doesn''t do >> anything at all. There are no errors also displayed. >> >> here is my rjs code: >> >> page << "appts.render(''BG'',0);" > Here is the problem resolution sequence: > > 1. Turn on browser''s javascript debugging (e.g. in Firefox take a look > at > javascript console or install a powerful FireBug extension). You''ll see > all > the javascript errors. > 2. Examine javascript code that is generated by RJS template. Make sure > that > it contains no errors (you can view RJS response in FireBug''s console). > 3. Make sure that the RJS response is properly evaled. E.g. in > Ajax.Request > there should be evalScripts options set to true. > 4. Make sure that you don''t overwrite RJS response''s content type and it > is > equal to "text/javascript" (you can view RJS response in FireBug''s > console). > > Hope that helpsI had already 1-4 covered. Here is the actual code that was spit on the debugger: try { appts.render(''BG'',0); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); appts.render(\''BG\'',0);''); throw e } There is no exception when this gets executed but the object doesn''t do anything. when i do --> page << "alert(appts);", i get this --> [object Object] any more ideas? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 19 October 2006 14:19, franee -- wrote:> I had already 1-4 covered. Here is the actual code that was spit on the > debugger: > > try { > appts.render(''BG'',0); > } catch (e) { alert(''RJS error:\n\n'' + e.toString()); > appts.render(\''BG\'',0);''); throw e } > > There is no exception when this gets executed but the object doesn''t do > anything. when i do --> page << "alert(appts);", i get this --> [object > Object] > > any more ideas?1. Try putting alert inside render() method to see if it actually get execute. If it is, then the problem is in your code, otherwise 2. Try exploring all "appts"''s object properties: function inspect(o) { var result = "Object "+o+" {\n"; for(attr in o) { result += ""+attr+" = "+o[attr]+"\n"; } result += "}\n"; return result; } Put this function into some place from where it could be loaded before RJS call (e.g. RAILS_ROOT/public/javascripts/application.js if you use javascript_include_tag :defaults) and then in RJS do "page << "alert(inspect(appts));" It might be that you''ve got wrong object. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Maxim Kulkin wrote:> On 19 October 2006 14:19, franee -- wrote: > >> Object] >> >> any more ideas? > 1. Try putting alert inside render() method to see if it actually get > execute. > If it is, then the problem is in your code, otherwise > 2. Try exploring all "appts"''s object properties: > > function inspect(o) { > var result = "Object "+o+" {\n"; > for(attr in o) { > result += ""+attr+" = "+o[attr]+"\n"; > } > result += "}\n"; > return result; > } > > Put this function into some place from where it could be loaded before > RJS > call (e.g. RAILS_ROOT/public/javascripts/application.js if you use > javascript_include_tag :defaults) and then in RJS do "page > << "alert(inspect(appts));" > > It might be that you''ve got wrong object.Thanks for the info. I think there''s something wrong with the js object or with RJS itself with complex objects. Its a pretty complex one which has multiple objects inside it. appts contains an array of appointment objects. each appointment object also contains a hash of measurement objects. when i call this on the page --> document.write(inspect(appts.appts[1].mds[''BG''])); it writes the contents of the object to the screen. but when i call the same thing inside the rjs template, it says Object undefined. pretty weird. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---