# Rjs $("aaa").insertHtml is not a function error

**URL:** <https://www.ruby-forum.com/t/rjs-aaa-inserthtml-is-not-a-function-error/96979>\
**Category:** Rails\
**Created:** [July 3, 2006, 10:25pm UTC](https://www.ruby-forum.com/t/rjs-aaa-inserthtml-is-not-a-function-error/96979 "2006-07-03T22:25:15Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ovidiu\_EFTIMIE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b9bd4f/32.png) [@Ovidiu\_EFTIMIE](https://www.ruby-forum.com/u/Ovidiu_EFTIMIE)\
**Post date:** [July 3, 2006, 10:25pm UTC](https://www.ruby-forum.com/t/rjs-aaa-inserthtml-is-not-a-function-error/96979/1 "2006-07-03T22:25:15Z")

</div>

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](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  
}

---

<div class="post-metadata">

**Author:** ![Ovidiu\_EFTIMIE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b9bd4f/32.png) [@Ovidiu\_EFTIMIE](https://www.ruby-forum.com/u/Ovidiu_EFTIMIE)\
**Post date:** [July 4, 2006, 3:16am UTC](https://www.ruby-forum.com/t/rjs-aaa-inserthtml-is-not-a-function-error/96979/2 "2006-07-04T03:16:59Z")

</div>

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” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Monday, July 03, 2006 3:24 PM  
Subject: [Rails] Rjs $(“aaa”).insertHtml is not a function error

---

<div class="post-metadata">

**Author:** ![Ovidiu\_EFTIMIE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b9bd4f/32.png) [@Ovidiu\_EFTIMIE](https://www.ruby-forum.com/u/Ovidiu_EFTIMIE)\
**Post date:** [July 5, 2006, 11:04pm UTC](https://www.ruby-forum.com/t/rjs-aaa-inserthtml-is-not-a-function-error/96979/3 "2006-07-05T23:04:37Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ovidiu\_EFTIMIE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b9bd4f/32.png) [@Ovidiu\_EFTIMIE](https://www.ruby-forum.com/u/Ovidiu_EFTIMIE)\
**Post date:** [July 6, 2006, 6:35am UTC](https://www.ruby-forum.com/t/rjs-aaa-inserthtml-is-not-a-function-error/96979/4 "2006-07-06T06:35:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ovidiu\_EFTIMIE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b9bd4f/32.png) [@Ovidiu\_EFTIMIE](https://www.ruby-forum.com/u/Ovidiu_EFTIMIE)\
**Post date:** [July 6, 2006, 11:43pm UTC](https://www.ruby-forum.com/t/rjs-aaa-inserthtml-is-not-a-function-error/96979/5 "2006-07-06T23:43:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ovidiu\_EFTIMIE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b9bd4f/32.png) [@Ovidiu\_EFTIMIE](https://www.ruby-forum.com/u/Ovidiu_EFTIMIE)\
**Post date:** [July 7, 2006, 8:40am UTC](https://www.ruby-forum.com/t/rjs-aaa-inserthtml-is-not-a-function-error/96979/6 "2006-07-07T08:40:22Z")

</div>

Thanx Bill,  
I’ll search those posts

---

<div class="post-metadata">

**Author:** ![Ovidiu\_EFTIMIE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b9bd4f/32.png) [@Ovidiu\_EFTIMIE](https://www.ruby-forum.com/u/Ovidiu_EFTIMIE)\
**Post date:** [July 6, 2006, 11:05pm UTC](https://www.ruby-forum.com/t/rjs-aaa-inserthtml-is-not-a-function-error/96979/7 "2006-07-06T23:05:15Z")

</div>

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’})%\>&nbsp;

 |

  
  

In new.rhtml I have:  
\<%= form\_tag ({:action =\> ‘create’},{:class =\>  
“f-wrap-1”,:onsubmit=\>“selectItem()”})%\>  
\<%= render :partial =\> ‘form’ %\>  
  
\<%= submit\_tag “Add” ,:class=\>“f-submit”%\> &nbsp;&nbsp;&nbsp;\<%=  
link\_to ‘Cancel’, :action =\> ‘list’ %\>  
\<%= end\_form\_tag %\>

I think this is all the relevant code.

Thanx,
