Forum: Ruby on Rails using inline insert_html to generate uniquely named elements

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Doug Pfeffer (Guest)
on 2006-06-07 06:37
Hello all,
Iâ??m using some inline rjs to add content with a unique id like so:

In the <head>:

function add_fields() {
html = '<div id="' + new Date().getTime() + '">';
html += "<%= escape_javascript(render :partial => 'field_set')
new Insertion.After("whatever", html);

In the body:
<%= link_to_function 'Add Fields', update_page{|page| 'add_fields'
} -%>

And it works, but I wish there was a more concise way to do it all in
the link_to(). Maybe by somehow including the getTime() wrapper bit
around a page.insert_html? I havenâ??t been able to get anything like that
to work, though. Any ideas?

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