It seems now if there is an incomplete / empty tab, the module breaks all the JS on the site.
I could not debug perfectly, but maybe this was the problematic part:

<div id="tabs-tabset" class="drupal-tabs js-hide"><div class="description"></div><ul class="clear-block"></ul></div>  </div>

I added a try-catch block to make it more robust. It's not an elegant solution, maybe you have a better idea to fix this inside the .module function. But at least it makes the JS code secure in that way that it does not break other JS at the site.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Aron Novak’s picture

Status: Active » Needs review
opteronmx’s picture

Title: Make the javascript of Tabs more robust » Javascript stops working with empty tabs - F is undefined

Changing title to be more descriptive.
-------

Issue confirmed.

I have the same issue on a node type with fieldgroups rendered as tabs. When all the fields inside the fieldgroups are empty, all the javascript on my site stops working.

Also, when I change from a browser's tab to another, I get the follow JS error on firebug:

"F is undefined"

On jquery_update.module's replacement file (jquery.min.js) for default drupal's jquery one. Or:

"elem is undefined"

on line

var id = elem[ expando ];

in the non-minimized jquery.js file.

The patch works, but I think that there must not be even an output on this conditions (all fields and all tabs empty). I've tried to fix it on tabs.module, but I didn't find what to validate as !empty().

nedjo’s picture

Status: Needs review » Needs work

Yeah, I think this needs to be done on the PHP side.

mogop’s picture

Had the same problem before.
I applied your patch but still can't load tabs even when they are not empty. maybe there is conflict with jquery_ui?

Failed to load resource: the server responded with a status of 403 (Forbidden)
/drupal/sites/all/modules/jquery_ui/jquery.ui/ui/packed/ui.tabs.packed.js?wFailed to load resource: the server responded with a status of 403 (Forbidden)
Aron Novak’s picture

Status: Needs work » Needs review
FileSize
1.4 KB

Now it's settled from the theme function, it simply does not print out code when there are not tabs.

Aron Novak’s picture

Any interest on this one? I think this fix is quite clean, isn't it?

mogop’s picture

Status: Patch (to be ported) » Needs review

I didn't try yet, sorry

HansKuiters’s picture

Tried patch #5: it works. Thanks.

Patrizio’s picture

Status: Needs review » Patch (to be ported)

+1 for patch #5

Status: Needs review » Patch (to be ported)