# Ajax window and Element.show when onclick

**URL:** <https://www.ruby-forum.com/t/ajax-window-and-element-show-when-onclick/164031>\
**Category:** Rails\
**Created:** [March 27, 2009, 1:49am UTC](https://www.ruby-forum.com/t/ajax-window-and-element-show-when-onclick/164031 "2009-03-27T01:49:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [March 27, 2009, 1:49am UTC](https://www.ruby-forum.com/t/ajax-window-and-element-show-when-onclick/164031/1 "2009-03-27T01:49:28Z")

</div>

in a page I have a list of modules in a div (left), and the  
permissions radio boxes for this module displyed on the irght  
when clicking on a module name, the related permissions are displayed

when using html, it works well… a click on a module label (on the  
left) show the element on the right (dib w permissions)  
BUT when using an Ajax form, the first display is correct, clicking on  
another module name reach directly to html page  
to show the permissions… so I was told that a JS error occursed…

looking into the Firebug console, I can see an error

Error : missing ) after argument list  
Source File : [http://localhost:3000/intranet-dev/admin](http://localhost:3000/intranet-dev/admin)  
Line : 1, Column : 65  
Source Code :  
showTab(‘boards’); this.blur(); Element.show(‘tab-content-boards’}):  
return false;  
---------------------------------------------------------------------------------------|  
arrow between } and )  
did I miss any specific parameter w Ajax ? this line execute  
correctly when html only

my form view :

\<% tabs = role\_permissions\_tabs %\>  
\<% selected\_tab = params[:tab] ? params[:tab].to\_s : tabs.first[:name]  
%\>

 \<% tabs.each do |tab| -%\> - \<%= link\_to tab[:label], { :tab =\> tab[:name] }, :id =\> "tab-#{tab[:name]}", :class =\> (tab[:name] != selected\_tab ? nil : 'selected'), :onclick =\> "showTab('#{tab[:name]}'); this.blur(); Element.show('tab-content-#{tab[:name]}'}): return false;" %\>
 \<% end -%\> 

 \<% tabs.each do |tab| -%\> \<%= content\_tag('div', render(:partial =\> 'roles/ permissions', :locals =\> {:perms =\> tab[:perms]}), :id =\> "tab- content-#{tab[:name]}", :style =\> (tab[:name] != selected\_tab ? 'display:none' : nil), :class =\> 'tab-content') %\> \<% end -%\> 

and the Showtab function in the js file

function showTab(name) {  
var f = $$(‘div#content .tab-content’);  
for(var i=0; i\<f.length; i++){  
Element.hide(f[i]);  
}  
var f = $$(‘div.tabs a’);  
for(var i=0; i\<f.length; i++){  
Element.removeClassName(f[i], “selected”);  
}  
Element.show(‘tab-content-’ + name);  
Element.addClassName(‘tab-’ + name, “selected”);  
return false;  
}
