Changed tab handling from binding a click handler on each tab to a <body> delegate targeting the same tabs
This commit is contained in:
parent
3f12a6877e
commit
c268f236f0
@ -13,13 +13,7 @@ $(document).ready(function() {
|
|||||||
/* Tabs Activiation
|
/* Tabs Activiation
|
||||||
================================================== */
|
================================================== */
|
||||||
|
|
||||||
var tabs = $('ul.tabs');
|
$('body').delegate('ul.tabs > li > a', 'click', function(e) {
|
||||||
|
|
||||||
tabs.each(function(i) {
|
|
||||||
|
|
||||||
//Get all tabs
|
|
||||||
var tab = $(this).find('> li > a');
|
|
||||||
tab.click(function(e) {
|
|
||||||
|
|
||||||
//Get Location of tab's content
|
//Get Location of tab's content
|
||||||
var contentLocation = $(this).attr('href');
|
var contentLocation = $(this).attr('href');
|
||||||
@ -30,13 +24,13 @@ $(document).ready(function() {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
//Make Tab Active
|
//Make Tab Active
|
||||||
tab.removeClass('active');
|
$(this).parent().siblings().children('a').removeClass('active');
|
||||||
$(this).addClass('active');
|
$(this).addClass('active');
|
||||||
|
|
||||||
//Show Tab Content & add active class
|
//Show Tab Content & add active class
|
||||||
$(contentLocation).show().addClass('active').siblings().hide().removeClass('active');
|
$(contentLocation).show().addClass('active')
|
||||||
|
.siblings().hide().removeClass('active');
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
Loading…
Reference in New Issue
Block a user