select active tab with links_to_remote

2 views
Skip to first unread message

Bruno Mendola

unread,
Jul 18, 2008, 5:25:32 AM7/18/08
to SeeSaw's Rails Widgets Users
Hello,

I can't manage to make tab switching in AJAX mode, putting
links_to_remote in the tabs definition.
The content changes, but the tab is always inactive, because
highlights_on works only when I load the entire page.

There is a way to change the active tab?

Thank you! :)

Bruno Mendola

unread,
Jul 18, 2008, 8:37:18 AM7/18/08
to SeeSaw's Rails Widgets Users
Ok, i solved the issue myself :)

I see that in the script generated when links_to_remote parameter is
used, there is a call to function "getElementsByClassName", that once
was only in Prototype, but now it is implemented in modern browsers.
Well, I think that some browsers, like Firefox 3 and Konqueror, have
something wrong with this function, because it has a bad behaviour
with the each iterator.

I solved the problem by replacing getElementsByClassName with the $$
function (http://www.prototypejs.org/api/utility/dollar-dollar).

In lib/widgets/tabnav_helper.rb, row 89
replace:
success = "document.getElementsByClassName('active', $('" +
@_tabnav.html[:id]+ "')).each(function(item)
{item.removeClassName('active');});"
with:
success = "$$
('##{@_tabnav.html[:id]} .active').each(function(item)
{item.removeClassName('active');});"


I hope this will help someone :)

Bye!
Reply all
Reply to author
Forward
0 new messages