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” [email protected]
To: [email protected]
Sent: Monday, July 03, 2006 3:24 PM
Subject: [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

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

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 L. 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

Thanx Bill,
I’ll search those posts

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:

<%= @actionTitle%>

            <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’})%> 



In new.rhtml I have:
<%= form_tag ({:action => ‘create’},{:class =>
“f-wrap-1”,:onsubmit=>“selectItem()”})%>
<%= render :partial => ‘form’ %>

<%= submit_tag “Add” ,:class=>“f-submit”%>    <%=
link_to ‘Cancel’, :action => ‘list’ %>
<%= end_form_tag %>

I think this is all the relevant code.

Thanx,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs