Forum: Ruby on Rails How to avoid auto-closing tag while using insert_html method

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
83c8cca11558f32207645ca270ae8475?d=identicon&s=25 Ye Dingding (Guest)
on 2007-06-28 20:14
(Received via mailing list)
It seems that
page.insert_html :bottom, 'current-entry', '<div id="cc" >'
will generate <div id="cc"/> 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.
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2007-06-28 20:23
(Received via mailing list)
On Jun 28, 2007, at 2:11 PM, Ye Dingding wrote:
> It seems that
> page.insert_html :bottom, 'current-entry', '<div id="cc" >'
> will generate <div id="cc"/> 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 <div> is what you think you need.

-Rob

Rob Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
83c8cca11558f32207645ca270ae8475?d=identicon&s=25 Ye Dingding (Guest)
on 2007-06-28 20:59
(Received via mailing list)
On 6/29/07, Rob Biedenharn <Rob@agileconsultingllc.com> 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 <div> 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
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2007-06-28 21:57
(Received via mailing list)
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 <div> 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
'<div id="cc" />' should be able to handle the equivalent of:

$('cc').innerHTML = "partial xxx"

<div id="cc" /> is the same as <div id="cc"></div>

Try it and see!

-Rob
This topic is locked and can not be replied to.