Karen Jenkin
2006-Sep-07 05:16 UTC
Help: error with example in "RJS Templates for Rails" book
Hi, I''m running through the examples in Cody Fauser''s "RJS Templates for Rails" PDF and have hit a small snag. Have implemented the first part of the expense tracker app, up to the section about FireBug. All is OK if I try the show view and add an expense from within Mozilla Firefox. However, if I try it from within IE and add an expense, I get a pop-up window RJS error: [object Error] then after clicking OK get another pop-up with new Insertion.bottom("expenses", "<tr id=\"expense-17\"> <td>test</td> <td class=\"amount\">200.00</td> </tr>"); new Effect.Highlight("expense-17",{}); Form.reset("expense-form"); If I refresh the show page the new entry is shown (i.e. made it into the d/b) I certainly don''t know enough about JS to work out what might be wrong with the above specific to IE. Any one else had this issue or know why this might be happening? Cheers, Karen -- 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 -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2006-Sep-07 20:21 UTC
Re: Help: error with example in "RJS Templates for Rails" book
The popups are just debug RJS, basically it tries to run the javascript and if it fails, an alert is called with the code it tried to run. Make sure that the elements you are tryinig to access (expenses, expense-17) are set up correctly (names vs ids). IE might act differently than Firefox (I can''t remember right off hand) when it comes to accessing DOM elements through id''s or name''s. I''d have to see the accompaning HTML to know for sure. Jason On 9/7/06, Karen Jenkin <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi, > > I''m running through the examples in Cody Fauser''s "RJS Templates for > Rails" PDF and have hit a small snag. > > Have implemented the first part of the expense tracker app, up to the > section about FireBug. All is OK if I try the show view and add an > expense from within Mozilla Firefox. However, if I try it from within > IE and add an expense, I get a pop-up window > RJS error: > [object Error] > > then after clicking OK get another pop-up with > new Insertion.bottom("expenses", "<tr id=\"expense-17\"> > <td>test</td> > <td class=\"amount\">200.00</td> > </tr>"); > new Effect.Highlight("expense-17",{}); > Form.reset("expense-form"); > > If I refresh the show page the new entry is shown (i.e. made it into the > d/b) > > I certainly don''t know enough about JS to work out what might be wrong > with the above specific to IE. > Any one else had this issue or know why this might be happening? > > Cheers, > Karen > > -- > 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 -~----------~----~----~----~------~----~------~--~---
Karen Jenkin
2006-Sep-08 01:14 UTC
Re: Help: error with example in "RJS Templates for Rails" bo
Jason Roelofs wrote:> The popups are just debug RJS, basically it tries to run the javascript > and > if it fails, an alert is called with the code it tried to run. Make sure > that the elements you are tryinig to access (expenses, expense-17) are > set > up correctly (names vs ids). IE might act differently than Firefox (I > can''t > remember right off hand) when it comes to accessing DOM elements through > id''s or name''s. I''d have to see the accompaning HTML to know for sure. > > JasonThe code is pulled straight from the book, so hope it''s OK to reproduce a snippet of the code here :-) In the show view, have: <h1><%= @project.name %></h1> <h2>Expenses</h2> <table id="expenses"> <tr><th>Description</th><th class="amount">Amount</th></tr> <%= render :partial => ''expenses/expense'', :collection => @project.expenses %> </table> <%= render :partial => ''expenses/new'' %> In the expense partial have: <tr id="expense-<%= expense.id %>"> <td><%=h expense.description %></td> <td class="amount"><%=h number_with_precision(expense.amount, 2) %></td> </tr> And in the new partial: <div id="new-expense"> <h3>Add an expense</h3> <% form_remote_for :expense, Expense.new, :url => hash_for_expenses_url(:project => @project, :action => ''new''), :html => { :id => ''expense-form'' } do |f| %> <label for="expense_description">Description:</label><br /> <%= f.text_field ''description'', :size => 60 %><br /> <label for="expense_amount">Amount:</label><br /> <%= f.text_field ''amount'', :size => 10 %><br /><br /> <%= submit_tag ''Add Expense'' %> <% end %> </div> So you can see how the DOM ids/names are setup. Does this highlight what might be the cause? (Therefore, the error I first posted relates to me adding a new expense which ends up with an id of 17.) Thanks Karen -- 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 -~----------~----~----~----~------~----~------~--~---