Forum: Ruby on Rails ajax window and Element.show when onclick

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ee0293412faca21e4ebf3326ed9d5f8c?d=identicon&s=25 Kad Kerforn (kadoudal)
on 2009-03-27 01:49
(Received via mailing list)
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
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]
%>

<div class="box" id="permissions">
  <div class="box_container" style="width:500px;">
  <div id="permissions_labels">
    <ul>
    <% tabs.each do |tab| -%>
        <li><%= 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;" %></li>
    <% end -%>
    </ul>
  </div>

  <div id="permissions_tabs">
    <% 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 -%>
  </div>
  </div>
</div>

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;
}
This topic is locked and can not be replied to.