# Insert\_html inserting fragment twice

**URL:** <https://www.ruby-forum.com/t/insert-html-inserting-fragment-twice/99906>\
**Category:** Rails\
**Created:** [July 26, 2006, 4:36am UTC](https://www.ruby-forum.com/t/insert-html-inserting-fragment-twice/99906 "2006-07-26T04:36:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![boram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7993a0/32.png) [@boram](https://www.ruby-forum.com/u/boram)\
**Post date:** [July 26, 2006, 4:36am UTC](https://www.ruby-forum.com/t/insert-html-inserting-fragment-twice/99906/1 "2006-07-26T04:36:37Z")

</div>

Has anyone had trouble with inline RJS insert\_html with the latest  
version of Rails?

My problem is that insert\_html inserts the html fragment twice. For  
example,

```
render :update do |page|
    page.insert_html :top, "some_list", "<li>booyow</li>"
end

```

would render “

- booyow
” twice.

Thanks.

---

<div class="post-metadata">

**Author:** ![boram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7993a0/32.png) [@boram](https://www.ruby-forum.com/u/boram)\
**Post date:** [July 26, 2006, 7:27am UTC](https://www.ruby-forum.com/t/insert-html-inserting-fragment-twice/99906/2 "2006-07-26T07:27:48Z")

</div>

I found the answer.

I had :complete =\> ‘eval(request.responseText)’ in my link\_to\_remote  
function, which was causing it to evaluate a second time. This  
behaviour is new in Rails 1.1.

mofo mofo wrote:

> Has anyone had trouble with inline RJS insert\_html with the latest  
> version of Rails?
> 
> My problem is that insert\_html inserts the html fragment twice. For  
> example,
> 
> ```
> render :update do |page|
> page.insert_html :top, "some_list", "<li>booyow</li>"
> end
> 
> ```
> 
> would render “
> 
> - booyow
> ” twice.
> 
> Thanks.

---

<div class="post-metadata">

**Author:** ![boram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7993a0/32.png) [@boram](https://www.ruby-forum.com/u/boram)\
**Post date:** [December 17, 2006, 2:53pm UTC](https://www.ruby-forum.com/t/insert-html-inserting-fragment-twice/99906/3 "2006-12-17T14:53:06Z")

</div>

hi can you explain more what you meant? basically what your  
link\_to\_remote looks like?

mine is simply

\<% link\_to\_remote “view comments”, :url =\> { :controller =\> ‘main’,  
:action =\> ‘test\_rjs’, Lid =\> @myObj%\>

my comments get inserted twice.

THANKS@!

mofo mofo wrote:

> I found the answer.
> 
> I had :complete =\> ‘eval(request.responseText)’ in my link\_to\_remote  
> function, which was causing it to evaluate a second time. This  
> behaviour is new in Rails 1.1.
> 
> mofo mofo wrote:
> 
> > Has anyone had trouble with inline RJS insert\_html with the latest  
> > version of Rails?
> > 
> > My problem is that insert\_html inserts the html fragment twice. For  
> > example,
> > 
> > ```
> > render :update do |page|
> > page.insert_html :top, "some_list", "<li>booyow</li>"
> > end
> > 
> > ```
> > 
> > would render “
> > 
> > - booyow
> > ” twice.
> > 
> > Thanks.

---

<div class="post-metadata">

**Author:** ![boram](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/7993a0/32.png) [@boram](https://www.ruby-forum.com/u/boram)\
**Post date:** [December 17, 2006, 8:54pm UTC](https://www.ruby-forum.com/t/insert-html-inserting-fragment-twice/99906/4 "2006-12-17T20:54:25Z")

</div>

solved it, i just use form\_to\_remote.
