ruby on rails - Using Javascript to change target div id in link_to -


so i'm using rails , nested_form, , have following link_to_add code:

<%= f.link_to_add :exptypes, id:"addtab", :data => { :target => "#exptype_new_3" } %>                 <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> add experimental type                  <script>                    $('#addtab').click(function() {                     add_tab('exptype');                   })                 </script>             <% end %> 

the page source looks this:

<li role="presentation">             <a class="add_nested_fields" data-association="exptypes" data-blueprint-id="exptypes_fields_blueprint" data-target="#exptype_new_3" href="javascript:void(0)" id="addtab">                 <span class="glyphicon glyphicon-plus" aria-hidden="true"></span> add experimental type                  <script>                    $('#addtab').click(function() {                     add_tab('exptype');                   })                 </script> </a>          </li> 

is there way inside javacript add_tab function change :target => "#exptype_new_3" else?

i'm trying div incremented everytime button clicked.

store arbitrary data associated matched elements or return value @ named data store first element in set of matched elements.

 $('#addtab').data('target', 'newtarget'); 

docs: http://api.jquery.com/data/


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -