# Id attribute partial problem in tab

**URL:** <https://www.ruby-forum.com/t/id-attribute-partial-problem-in-tab/143912>\
**Category:** Rails\
**Created:** [July 23, 2008, 7:54pm UTC](https://www.ruby-forum.com/t/id-attribute-partial-problem-in-tab/143912 "2008-07-23T19:54:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![quest4](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/c67d28/32.png) [@quest4](https://www.ruby-forum.com/u/quest4)\
**Post date:** [July 23, 2008, 7:54pm UTC](https://www.ruby-forum.com/t/id-attribute-partial-problem-in-tab/143912/1 "2008-07-23T19:54:14Z")

</div>

I have used [JavaScript Tabifier automatically create an html css tabs interface](http://www.barelyfitz.com/projects/tabber/) in my rails  
view. My problem is when I place a partial in the second tab I lose  
access to the global @model.id attribute for reference purposes with  
the draggable\_element.

\<% for pdf in @article.pdfs %\>  
\<%= image\_tag pdf.title,  
:style =\> “vertical-align: middle”,  
:id =\> “#{@article.id}\_#{pdf.id}”,  
:class =\> “attached\_pdf” %\>

\<%= draggable\_element “#{@article.id}\_#{pdf.id}”, :revert =\> true %\>  
\<% end %\>

If I use “#{@article.title}\_#{pdf.id}” for the image\_tag :id and  
draggable\_element id it works without problem. If I place the render  
partial call in the first tab it works without problems…

Any ideas?

---

<div class="post-metadata">

**Author:** ![quest4](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/c67d28/32.png) [@quest4](https://www.ruby-forum.com/u/quest4)\
**Post date:** [July 24, 2008, 7:29am UTC](https://www.ruby-forum.com/t/id-attribute-partial-problem-in-tab/143912/2 "2008-07-24T07:29:00Z")

</div>

The problem was the :id was not unique and clashed with other  
draggable attachments on different tabs.

By adding a unique string to the beginning of the id solved the  
problem:

:id =\> “pdflibrary\_#{@article.id}\_#{pdf.id}”
