# Prototype.js insert issue

**URL:** <https://www.ruby-forum.com/t/prototype-js-insert-issue/168391>\
**Category:** Rails\
**Created:** [May 20, 2009, 10:19am UTC](https://www.ruby-forum.com/t/prototype-js-insert-issue/168391 "2009-05-20T10:19:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@sudhi](https://www.ruby-forum.com/u/sudhi)\
**Post date:** [May 20, 2009, 10:19am UTC](https://www.ruby-forum.com/t/prototype-js-insert-issue/168391/1 "2009-05-20T10:19:24Z")

</div>

Hi,

I am trying to use the following lines in my RJS and have a problem

page.insert\_html :bottom,:list,"

"  
#some conditions checks  
page.insert\_html :bottom,:list,“- Hello item
”  
#some more code to add - s  
page.insert\_html :bottom,:list,"

"

The problem I am having is the first line \<\<page.insert\_html  
:bottom,:list,"

"\>\> automatically closes 
 if I see with firebug  
the output is

  - Hello item

Which is wrong

Using prototype how do I only insert a start tag

?

Thanks,  
Sudhindra

---

<div class="post-metadata">

**Author:** ![sudhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@sudhi](https://www.ruby-forum.com/u/sudhi)\
**Post date:** [May 20, 2009, 1:00pm UTC](https://www.ruby-forum.com/t/prototype-js-insert-issue/168391/2 "2009-05-20T13:00:36Z")

</div>

On May 20, 9:19 am, Sudhi K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> The problem I am having is the first line \<\<page.insert\_html  
> :bottom,:list,“
> 
> ”\>\> automatically closes 
> if I see with firebug  
> the output is
> 
> - Hello item
> 
> Which is wrong
> 
> Using prototype how do I only insert a start tag
> 
> ?

looks like either prototype or the browser is fixing your html (as  
inserting just

 would be invalid). Your best bet is to build up  
all you want to insert and insert it in one go.

Fred

---

<div class="post-metadata">

**Author:** ![sudhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@sudhi](https://www.ruby-forum.com/u/sudhi)\
**Post date:** [May 20, 2009, 1:52pm UTC](https://www.ruby-forum.com/t/prototype-js-insert-issue/168391/3 "2009-05-20T13:52:21Z")

</div>

Sudhi K. wrote:

> Hi,
> 
> I am trying to use the following lines in my RJS and have a problem
> 
> page.insert\_html :bottom,:list,“
> 
> ”  
> #some conditions checks  
> page.insert\_html :bottom,:list,“- Hello item
> ”  
> #some more code to add - s  
> page.insert\_html :bottom,:list,“
> 
> ”

Hi,  
Why don’t you try using jquery.js. Works great with rails too and is  
simpler than prototype.js.

Reference -  
[http://jimneath.org/2008/06/18/using-jquery-with-ruby-on-rails/](http://jimneath.org/2008/06/18/using-jquery-with-ruby-on-rails/)

Thanks,  
Manasi
