I don't want the first tab always to be the active one. What I had in mind was to use javascript to select the active tab.
In jquery tabs online documentation I found I should use something like
<?php
drupal_add_js(
'$(document).ready(function() {
$("#tabs-mini-panel-mp_2right-middle > ul").tabs({selected: 2});
});', 'inline');
?>
where the name after # is the tabs css ID.
It doesn't do anything though - any advice is greatly appreciated!
btw, i tried the code by creating a new node and setting the input to php. Also, the tabs I want to change appear on the same page as the node that contains this code.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | tabs.js.txt | 4.04 KB | roblivian |
Comments
Comment #1
dawehnerthis is not a bug of the tabs panels style module.
Its rather a missing feature of the tabs module / jquery tools tabs
So you would have to add the feature to the js file of the tab
Comment #2
Apfel007 commentedHi,
did someone implement the function to change the active tab on pageload?
Comment #3
nedjoI think what we need to do is: (a) add a class on the selected tab then (b) in the JS, switch to that tab on load.
I'd welcome a patch.
Comment #4
Apfel007 commentedmhm I saw, that they ad a class with the last patch.. but I don't know how to use this... and JS... it's not my favorite.. :-)
Comment #5
roblivian commentedwould it make sense to add a "selected" setting handled by tabs.js, and which could then be modified by modules?:
any thoughts?
edit: quick proof-of-concept, and i think this works, but would welcome any input. patch to tabs.js follows:
Comment #6
VSZ commentedHow to manually patch tabs.js?
Where in tabs.js the lines should be added?
Thank you.
Comment #7
roblivian commentedi placed the new settings check (the "if (Drupal.settings.tabs.selected)...") at line 12, and the "selected: selected," at line 27.
i've also attached a patched tabs.js to this comment.
i'd be interested in hearing if it works for you....cheers.
Comment #8
Apfel007 commentedHi roblivian,
thanks for the patch , but it seems, that this don't work for me.. cleared cache, do update.php. same think as before? Could that be?
Cheers
Comment #9
Apfel007 commentedAnyone out there - who had solve this?
Comment #10
slip commentedworked for me.
I was thinking this would be a cool feature coupled up with a $_GET variable.
Comment #11
Apfel007 commentedHi there,
I can't get this to work .. could someone help me? Where and how to put this?
Do I need this? How can I change this value on click ? It should be able to change -or ??
Comment #12
nedjoI added support for a new attribute, '#selected', which can be set for tabpage elements. If set to TRUE, the tab will be selected on load. See the updated example in tabsexample.module.
Comment #14
sudhindracn commentedThanks, it works like charm...