0

I have a content type with field collections. I want to open an overlay to edit a node but switch to a tab for a specific field collection. Does anyone know how I can do this?

I can open the overlay with #overlay=node/16/edit, but this will just go to the first vertical tab.

2
  • If you know the tab path, can't you just set the #overlay path to that? – Jukebox Sep 21 '11 at 3:18
  • the tabs do not have paths. clicking on them does not change the path. – Ali Gangji Sep 21 '11 at 7:13
3

I took a look at vertical-tabs.js, and as best I can tell you'll have to add some JS to the page to trigger the click event on the correct link. On line 33, the Drupal.verticalTab object gets instantiated, but not assigned to a namespace where you can get to it later to run its focus() method. (This would be a good thing to fix in D8. Hmm.)

So basically, you need a .js file that does something like

(function ($) {
  Drupal.behaviors.yourModuleName = {
    attach: function (context, settings) {
      $('a:contains("Revision information")').click();
    }
  };
})(jQuery);

where "Revision information" is the actual text of the link that opens your vertical tab.

Note: There is some URL fragment handling in vertical-tabs.js, which I think is supposed to make it so that if you set the URL fragment to the id of a fieldset, that vertical tab will open automatically. It might be worth trying, but I couldn't get it to work even on a non-overlay page.

1
  • I can confirm that I wasn't able to set the vertical tab through the id either, might be a bug. – Berdir Oct 4 '11 at 22:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.