Ovidiu EFTIMIE
2006-Jul-03 20:24 UTC
[Rails] Rjs $("aaa").insertHtml is not a function error
Hi, I''ve searched the list and found that someone had the same problem as me http://lists.rubyonrails.org/pipermail/rails/2006-May/043760.html I''m have in my page a link like this <%= link_to_remote ("Add #{image_tag(''add.png'')}",:url=>{:action=>''addProduct''})%> and in my controller def addProduct .................. render :update do |page| page[:productsTable].insert_html :partial=>"entryProduct" page.visual_effect :highlight,'':productsTable'' end end entryProduct partial is in _entryProduct.rhtml If I use replace_html instead of insert_Html it works fine. I don''t know exactly what I''m doing wrong. The response reported by Firebug is try { $("productsTable").insertHtml({"partial": "entryProduct"}); new Effect.Highlight(":productsTable",{}); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''$(\"productsTable\").insertHtml({\"partial\": \"entryProduct\"});\nnew effect.Highlight(\":productsTable\",{});''); throw e }
I didn''t see your original post but would suggest you check to make sure your "aaa" id is unique on the page. I recently had a somewhat similar problem. hth, Bill ----- Original Message ----- From: "Ovidiu EFTIMIE" <eovidiu@gmail.com> To: <rails@lists.rubyonrails.org> Sent: Monday, July 03, 2006 3:24 PM Subject: [Rails] Rjs $("aaa").insertHtml is not a function error> Hi, > I''ve searched the list and found that someone had the same problem as me > http://lists.rubyonrails.org/pipermail/rails/2006-May/043760.html > I''m have in my page a link like this > <%= link_to_remote ("Add > #{image_tag(''add.png'')}",:url=>{:action=>''addProduct''})%> > and in my controller > def addProduct > .................. > render :update do |page| > page[:productsTable].insert_html :partial=>"entryProduct" > page.visual_effect :highlight,'':productsTable'' > end > end > > entryProduct partial is in _entryProduct.rhtml > If I use replace_html instead of insert_Html it works fine. I don''t > know exactly what I''m doing wrong. > The response reported by Firebug is > try { > $("productsTable").insertHtml({"partial": "entryProduct"}); > new Effect.Highlight(":productsTable",{}); > } catch (e) { > alert(''RJS error:\n\n'' + e.toString()); > alert(''$(\"productsTable\").insertHtml({\"partial\": > \"entryProduct\"});\nnew > effect.Highlight(\":productsTable\",{});''); > throw e > } > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Ovidiu EFTIMIE
2006-Jul-05 21:03 UTC
[Rails] Rjs $("aaa").insertHtml is not a function error
I''ve checked an the id is unique. When I''m using replace_html instead of insert_html it works fine. More to that: if I change the code from the addproduct method to def addProduct .................. return render :action => ''entryProduct.rjs'' if request.xhr? end and in the entryProduct.rjs I have page.insert_html :bottom,''productsTable'',:partial=>"entryProduct" it works fine. Does anyone has any ideea what I''m doing wrong in the first place ? Thanx On 7/4/06, Bill Walton <bill.walton@charter.net> wrote:> I didn''t see your original post but would suggest you check to make sure > your "aaa" id is unique on the page. I recently had a somewhat similar > problem. > > hth, > Bill > ----- Original Message ----- > From: "Ovidiu EFTIMIE" <eovidiu@gmail.com> > To: <rails@lists.rubyonrails.org> > Sent: Monday, July 03, 2006 3:24 PM > Subject: [Rails] Rjs $("aaa").insertHtml is not a function error > > > > Hi, > > I''ve searched the list and found that someone had the same problem as me > > http://lists.rubyonrails.org/pipermail/rails/2006-May/043760.html > > I''m have in my page a link like this > > <%= link_to_remote ("Add > > #{image_tag(''add.png'')}",:url=>{:action=>''addProduct''})%> > > and in my controller > > def addProduct > > .................. > > render :update do |page| > > page[:productsTable].insert_html :partial=>"entryProduct" > > page.visual_effect :highlight,'':productsTable'' > > end > > end > > > > entryProduct partial is in _entryProduct.rhtml > > If I use replace_html instead of insert_Html it works fine. I don''t > > know exactly what I''m doing wrong. > > The response reported by Firebug is > > try { > > $("productsTable").insertHtml({"partial": "entryProduct"}); > > new Effect.Highlight(":productsTable",{}); > > } catch (e) { > > alert(''RJS error:\n\n'' + e.toString()); > > alert(''$(\"productsTable\").insertHtml({\"partial\": > > \"entryProduct\"});\nnew > > effect.Highlight(\":productsTable\",{});''); > > throw e > > } > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Ovidiu EFTIMIE wrote:> I''ve checked an the id is unique. > When I''m using replace_html instead of insert_html it works fine. > More to that: if I change the code from the addproduct method to > def addProductIt sounds to me like you might have a typo somewhere in there. If you''d post all the relevant code, maybe we can help you find it. Or whatever it is. Best regards, Bill
Ovidiu EFTIMIE
2006-Jul-06 21:04 UTC
[Rails] Rjs $("aaa").insertHtml is not a function error
Hi Bill, In the controller I have #entries_controller.rb def addProduct render :update do |page| page[:productsTable].insert_html :bottom,:partial=>"entryProduct" page.visual_effect :highlight,'':productsTable'' end end in _form.rhtml: <fieldset id="frm"> <legend><%= @actionTitle%></legend> <table border="0" width="100%"> <tr> <td valign ="top" > <table border="1" id="productsTable" width="100%"> <tr> <td width="70%">Produs</td> <td>Cantitate</td> <td><%= link_to_remote ("Add #{image_tag(''add.png'')}",:url=>{:action=>''addProduct''})%> </td> </tr> </table> </td> </tr> </fieldset> In new.rhtml I have: <%= form_tag ({:action => ''create''},{:class => "f-wrap-1",:onsubmit=>"selectItem()"})%> <%= render :partial => ''form'' %><br> <%= submit_tag "Add" ,:class=>"f-submit"%> <%link_to ''Cancel'', :action => ''list'' %> <%= end_form_tag %> I think this is all the relevant code. Thanx, On 7/6/06, Bill Walton <bill.walton@charter.net> wrote:> Ovidiu EFTIMIE wrote: > > > > I''ve checked an the id is unique. > > When I''m using replace_html instead of insert_html it works fine. > > More to that: if I change the code from the addproduct method to > > def addProduct > > It sounds to me like you might have a typo somewhere in there. If you''d > post all the relevant code, maybe we can help you find it. Or whatever it > is. > > Best regards, > Bill > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Hi Ovidiu, The problem you''re having is that it''s not possible to insert_html inside a table. You have to replace the whole table, which is why the replace works. There were some posts on the list earlier today from Ryan Lundie who was having the same problem. He came up with a link that explained the problem. You might want to look back and see those. Best regards, Bill Ovidiu EFTIMIE wrote:> > in _form.rhtml: > > <fieldset id="frm"> > <legend><%= @actionTitle%></legend> > <table border="0" width="100%"> > <tr> > <td valign ="top" > > > <table border="1" id="productsTable" width="100%"> > <tr> > <td width="70%">Produs</td> > <td>Cantitate</td> > <td><%= link_to_remote ("Add > #{image_tag(''add.png'')}",:url=>{:action=>''addProduct''})%> </td> > </tr> > </table> > </td> > </tr> > </fieldset>
Ovidiu EFTIMIE
2006-Jul-07 06:39 UTC
[Rails] Rjs $("aaa").insertHtml is not a function error
Thanx Bill, I''ll search those posts On 7/7/06, Bill Walton <bill.walton@charter.net> wrote:> Hi Ovidiu, > > The problem you''re having is that it''s not possible to insert_html inside a > table. You have to replace the whole table, which is why the replace works. > There were some posts on the list earlier today from Ryan Lundie who was > having the same problem. He came up with a link that explained the problem. > You might want to look back and see those. > > Best regards, > Bill > > Ovidiu EFTIMIE wrote: > > > > in _form.rhtml: > > > > <fieldset id="frm"> > > <legend><%= @actionTitle%></legend> > > <table border="0" width="100%"> > > <tr> > > <td valign ="top" > > > > > <table border="1" id="productsTable" width="100%"> > > <tr> > > <td width="70%">Produs</td> > > <td>Cantitate</td> > > <td><%= link_to_remote ("Add > > #{image_tag(''add.png'')}",:url=>{:action=>''addProduct''})%> </td> > > </tr> > > </table> > > </td> > > </tr> > > </fieldset> > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >