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

**URL:** <https://www.ruby-forum.com/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/108058>\
**Category:** Rails\
**Created:** [June 28, 2007, 8:14pm UTC](https://www.ruby-forum.com/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/108058 "2007-06-28T20:14:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ye\_Dingding](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/49beb7/32.png) [@Ye\_Dingding](https://www.ruby-forum.com/u/Ye_Dingding)\
**Post date:** [June 28, 2007, 8:14pm UTC](https://www.ruby-forum.com/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/108058/1 "2007-06-28T20:14:15Z")

</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:** ![Ye\_Dingding](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/49beb7/32.png) [@Ye\_Dingding](https://www.ruby-forum.com/u/Ye_Dingding)\
**Post date:** [June 28, 2007, 8:23pm UTC](https://www.ruby-forum.com/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/108058/2 "2007-06-28T20:23:17Z")

</div>

On Jun 28, 2007, at 2:11 PM, Ye Dingding wrote:

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

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Ye\_Dingding](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/49beb7/32.png) [@Ye\_Dingding](https://www.ruby-forum.com/u/Ye_Dingding)\
**Post date:** [June 28, 2007, 8:59pm UTC](https://www.ruby-forum.com/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/108058/3 "2007-06-28T20:59:27Z")

</div>

On 6/29/07, Rob B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

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

-Rob

---

<div class="post-metadata">

**Author:** ![Ye\_Dingding](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/49beb7/32.png) [@Ye\_Dingding](https://www.ruby-forum.com/u/Ye_Dingding)\
**Post date:** [June 28, 2007, 9:57pm UTC](https://www.ruby-forum.com/t/how-to-avoid-auto-closing-tag-while-using-insert-html-method/108058/4 "2007-06-28T21:57:36Z")

</div>

On Jun 28, 2007, at 2:58 PM, Ye Dingding wrote:

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