mercredi 25 mars 2015

How to overwrite behaviour of function in javascript


I am trying to override the behaviour of a javascript function for a website that I am developing. I am new to javascript and I am having a problem figuring this out. I have watched several videos and did some reading and this is what I came up with.



jQuery(document).ready(function ($) {

function displayTab(element) {
alert('here'); // test that I am getting here
var tab = Drupal.quicktabs.tab
// Set tab to active.
$(this).parents('li').siblings().removeClass('active');
$(this).parents('li').addClass('active');

// Hide all tabpages.
tab.container.children().addClass('quicktabs-hide');

if (!tab.tabpage.hasClass("quicktabs-tabpage")) {
tab = new Drupal.quicktabs.tab(element);
}

tab.tabpage.removeClass('quicktabs-hide');
return false;
}

if ($( '#quicktabs-menu_block').length > 0) {
$('#quicktabs-menu_block .quicktabs-tabs li').each(function() {
$('a', this).bind({
mouseenter: function(){
$(this).displayTab($(this));
}
});
});
}
});


This is not working - the function is never called. I am not sure what that is, but obviously I am missing something fundamental. What am I missing?





Aucun commentaire:

Enregistrer un commentaire