Forum: Ruby on Rails prototype.js insert issue

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.
Sudhi K. (Guest)
on 2009-05-20 12:19
Hi,

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

page.insert_html :bottom,:list,"<ul>"
#some conditions checks
page.insert_html :bottom,:list,"<li>Hello item</li>"
#some more code to add <li>s
page.insert_html :bottom,:list,"</ul>"


The problem I am having is the first line <<page.insert_html
:bottom,:list,"<ul>">> automatically closes <ul> if I see with firebug
the output is

<ul></ul>
<li>Hello item</li>
</ul>
Which is wrong

Using prototype how do I only insert a start tag <ul>?

Thanks,
Sudhindra
Frederick C. (Guest)
on 2009-05-20 15:00
(Received via mailing list)
On May 20, 9:19 am, Sudhi K. <removed_email_address@domain.invalid>
wrote:
> The problem I am having is the first line <<page.insert_html
> :bottom,:list,"<ul>">> automatically closes <ul> if I see with firebug
> the output is
>
> <ul></ul>
> <li>Hello item</li>
> </ul>
> Which is wrong
>
> Using prototype how do I only insert a start tag <ul>?
>
looks like either prototype or the browser is fixing your html (as
inserting just <ul> would be invalid). Your best bet is to build up
all you want to insert and insert it in one go.

Fred
Manasi V. (Guest)
on 2009-05-20 15:52
Sudhi K. wrote:
> Hi,
>
> I am trying to use the following lines in my RJS and have a problem
>
> page.insert_html :bottom,:list,"<ul>"
> #some conditions checks
> page.insert_html :bottom,:list,"<li>Hello item</li>"
> #some more code to add <li>s
> page.insert_html :bottom,:list,"</ul>"
>


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

Thanks,
Manasi
This topic is locked and can not be replied to.