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.

CommentFileSizeAuthor
#7 tabs.js.txt4.04 KBroblivian

Comments

dawehner’s picture

Project: Panels Tabs » Tabs (jQuery UI tabs)
Version: 5.x-1.5 » 6.x-1.x-dev

this 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

Apfel007’s picture

Hi,
did someone implement the function to change the active tab on pageload?

nedjo’s picture

I 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.

Apfel007’s picture

mhm 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.. :-)

roblivian’s picture

would it make sense to add a "selected" setting handled by tabs.js, and which could then be modified by modules?:

  $settings = array(
    'tabs' => array(
      'selected' => 3,
    ),
  );

  drupal_add_js($settings, 'setting');

any thoughts?

edit: quick proof-of-concept, and i think this works, but would welcome any input. patch to tabs.js follows:

12,16d11
<   if (Drupal.settings.tabs.selected) {
<     selected = Drupal.settings.tabs.selected;
<   } else {
<     selected = '0';
<   }
27d21
<       selected: selected,
VSZ’s picture

How to manually patch tabs.js?
Where in tabs.js the lines should be added?

Thank you.

roblivian’s picture

StatusFileSize
new4.04 KB

i 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.

Apfel007’s picture

Hi 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

Apfel007’s picture

Anyone out there - who had solve this?

slip’s picture

worked for me.

I was thinking this would be a cool feature coupled up with a $_GET variable.

Apfel007’s picture

Hi there,

I can't get this to work .. could someone help me? Where and how to put this?

 ... 
$settings = array(
    'tabs' => array(
      'selected' => 3,
    ),
  );

Do I need this? How can I change this value on click ? It should be able to change -or ??

nedjo’s picture

Status: Active » Fixed

I 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sudhindracn’s picture

Thanks, it works like charm...