I was attempting to use magic_tabs in combination with collapse.js. It worked fine on the initially loaded tab, but when the tab is switched to a new tab the collapse functionality is lost. From what I can tell this is because the tab change doesn't call Drupal.attachBehaviors. Is this something that magic_tabs should do or do I need to do this myself somehow?

Comments

esclapes’s picture

Having the same problem with collapse.js and lightbox.js

Does anybody have more info about how to call the attachBehaviours function?

esclapes’s picture

I think I got it working... I had to dive a bit into unknown territory: http://drupal.org/node/114774#javascript-behaviors

I just added the attachBehaviors to the onclick event (I had to hack the module, which I did not want to, but don't know any other way):
Around line 140:


'onclick' => "
            $('#$callback .magic_content').addClass('hidden');
            $('#$callback .loading').removeClass('hidden');
            $('#$callback').load('$cb_path');
            Drupal.attachBehaviors(#$callback); 
            return false;",
esclapes’s picture

Uuups!

Just realized that this solution is not loading the section by ajax, but reloading the whole page... any better solution?

esclapes’s picture

OK! I think I got it now. I launch the attachBehaviors funtion as a callback functions (defined for the jquery command $.load)

'onclick' => "
            $('#$callback .magic_content').addClass('hidden');
            $('#$callback .loading').removeClass('hidden');
            $('#$callback').load('$cb_path', function(){
                    Drupal.attachBehaviors(this);
	  }
            );
            return false;",
jsobiecki’s picture

Thank you. Your solution works for me too :)

WildKitten’s picture

Thank you ciberligre! After hours and hours searching for solution, yours one worked like a charm!

Aleksey Zubko’s picture

Thank you. Solution works for me too