# Js call with rails generated attributes (item ids)

**URL:** <https://www.ruby-forum.com/t/js-call-with-rails-generated-attributes-item-ids/135590>\
**Category:** Rails\
**Created:** [April 23, 2008, 12:34pm UTC](https://www.ruby-forum.com/t/js-call-with-rails-generated-attributes-item-ids/135590 "2008-04-23T12:34:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 23, 2008, 12:34pm UTC](https://www.ruby-forum.com/t/js-call-with-rails-generated-attributes-item-ids/135590/1 "2008-04-23T12:34:02Z")

</div>

hi. i want do call my js method “appear(box1, box2)” with rails created,  
dynamic ids for my div tags --\>

:complete =\> “appear(’\<%= dom\_id(person.id)box %\>’,’\<%=  
dom\_id(person.id) %\>’)” %\>

…unfortunatly, that doesn’t work: syntax error, unexpected $end,  
expecting ‘)’ and so on.

how has the js call to look like? i hope u r able to help me.  
here s the code snippet:

\<% unless person.about == “” %\>

\<%= link\_to\_remote “mehr”,  
:url=\>{:action =\> “showMore”},  
:update =\> dom\_id(person.id),  
:complete =\> “appear(’\<%= dom\_id(person.id)box %\>’,’\<%=  
dom\_id(person.id) %\>’)” %\>

\<% end %\>

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 23, 2008, 12:40pm UTC](https://www.ruby-forum.com/t/js-call-with-rails-generated-attributes-item-ids/135590/2 "2008-04-23T12:40:31Z")

</div>

On 23 Apr 2008, at 11:34, Claus S. wrote:

> hi. i want do call my js method “appear(box1, box2)” with rails  
> created,  
> dynamic ids for my div tags --\>
> 
> :complete =\> “appear(’\<%= dom\_id(person.id)box %\>’,’\<%=  
> dom\_id(person.id) %\>’)” %\>

that string is just a string (ie it’s not put through erb)  
“appear(’#{dom\_id(person.id)}box’,’#{dom\_id(person.id)’)”

should do the trick

Fred

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 23, 2008, 12:45pm UTC](https://www.ruby-forum.com/t/js-call-with-rails-generated-attributes-item-ids/135590/3 "2008-04-23T12:45:32Z")

</div>

> “appear(’#{dom\_id(person.id)}box’,’#{dom\_id(person.id)’)”
> 
> should do the trick

thanx a lot.

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 23, 2008, 2:52pm UTC](https://www.ruby-forum.com/t/js-call-with-rails-generated-attributes-item-ids/135590/4 "2008-04-23T14:52:53Z")

</div>

Frederick C. wrote:

> On 23 Apr 2008, at 11:34, Claus S. wrote:
> 
> > hi. i want do call my js method “appear(box1, box2)” with rails  
> > created,  
> > dynamic ids for my div tags --\>
> > 
> > :complete =\> “appear(’\<%= dom\_id(person.id)box %\>’,’\<%=  
> > dom\_id(person.id) %\>’)” %\>
> 
> that string is just a string (ie it’s not put through erb)  
> “appear(’#{dom\_id(person.id)}box’,’#{dom\_id(person.id)’)”
> 
> should do the trick

sorry for disturbing again: now the produced html code is ok, but my  
script isn’t called. i use this script on an other site, thus i’m sure  
the script is ok. can u think about a reason for that problem.

---

<div class="post-metadata">

**Author:** ![claus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/82dd89/32.png) [@claus](https://www.ruby-forum.com/u/claus)\
**Post date:** [April 23, 2008, 2:55pm UTC](https://www.ruby-forum.com/t/js-call-with-rails-generated-attributes-item-ids/135590/5 "2008-04-23T14:55:39Z")

</div>

On 23 Apr 2008, at 13:52, Claus S. wrote:

> > > dom\_id(person.id) %\>’)" %\>  
> > > sure  
> > > the script is ok. can u think about a reason for that problem.

Use firebug to see what’s going on (eg set a breakpoint in your appear  
function).

Fred
