# How to avoid auto-closing tag while using insert\_html method?

**URL:** <https://discuss.rubyonrails.org/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/15039>\
**Category:** rubyonrails-talk\
**Created:** [June 28, 2007, 6:11pm UTC](https://discuss.rubyonrails.org/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/15039 "2007-06-28T18:11:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dingding\_Ye](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@Dingding\_Ye](https://discuss.rubyonrails.org/u/Dingding_Ye)\
**Post date:** [June 28, 2007, 6:11pm UTC](https://discuss.rubyonrails.org/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/15039/1 "2007-06-28T18:11:51Z")

</div>

It seems that

page.insert\_html :bottom, ‘current-entry’, ‘

’

will generate

 automatically. That is, it auto-close the 'div' tag.

However, this is not i want. What I want is a unclosing tag. So, Is there any way to achieve the goal?

thx.

---

<div class="post-metadata">

**Author:** ![rab](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/rab/32/710_2.png) [@rab](https://discuss.rubyonrails.org/u/rab)\
**Post date:** [June 28, 2007, 6:22pm UTC](https://discuss.rubyonrails.org/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/15039/2 "2007-06-28T18:22:32Z")

</div>

I think that the HTML fragment has to be “complete” so it’s not valid to do what you ask. Perhaps you could state what your true goal is? Or explain the other options that you’ve considered and why an opening

 is what you think you need.

-Rob

Rob Biedenharn [http://agileconsultingllc.com](http://agileconsultingllc.com)

[Rob@AgileConsultingLLC.com](mailto:Rob@AgileConsultingLLC.com)

---

<div class="post-metadata">

**Author:** ![Dingding\_Ye](https://avatars.discourse-cdn.com/v4/letter/d/b4bc9f/32.png) [@Dingding\_Ye](https://discuss.rubyonrails.org/u/Dingding_Ye)\
**Post date:** [June 28, 2007, 6:58pm UTC](https://discuss.rubyonrails.org/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/15039/3 "2007-06-28T18:58:32Z")

</div>

> > It seems that
> > 
> > page.insert\_html :bottom, ‘current-entry’, ‘
> > 
> > ’

> > will generate
> > 
> > automatically. That is, it auto-close the ‘div’ tag.
> > 
> > However, this is not i want. What I want is a unclosing tag. So, Is there any way to achieve the goal?
> > 
> > thx.

> 

> I think that the HTML fragment has to be “complete” so it’s not valid to do what you ask. Perhaps you could state what your true goal is? Or explain the other options that you’ve considered and why an opening
> 
> is what you think you need.

I want the inner\_html in the div can be replacable. That’s, page.replace\_html “cc”, :partial =\> “xxx” If it’s not valid, i’ll turn to use another way to change the content.

---

<div class="post-metadata">

**Author:** ![rab](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/rab/32/710_2.png) [@rab](https://discuss.rubyonrails.org/u/rab)\
**Post date:** [June 28, 2007, 7:53pm UTC](https://discuss.rubyonrails.org/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/15039/4 "2007-06-28T19:53:42Z")

</div>

> > > It seems that page.insert\_html :bottom, ‘current-entry’, ‘
> > > 
> > > ’

> > > will generate
> > > 
> > > automatically. That is, it auto-close the ‘div’ tag.
> > > 
> > > However, this is not i want. What I want is a unclosing tag. So, Is there any way to achieve the goal?
> > > 
> > > thx.

> >

> > I think that the HTML fragment has to be “complete” so it’s not valid to do what you ask. Perhaps you could state what your true goal is? Or explain the other options that you’ve considered and why an opening
> > 
> > is what you think you need.

> I want the inner\_html in the div can be replacable. That’s, page.replace\_html “cc”, :partial =\> “xxx” If it’s not valid, i’ll turn to use another way to change the content.

If that is something that will happen in some future request, then ‘

’ should be able to handle the equivalent of:

$(‘cc’).innerHTML = “partial xxx”

 is the same as 

Try it and see!

-Rob
