Skip to content

Commit

Permalink
Fix event delegation on tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicinabox committed Aug 8, 2012
1 parent 4d4d261 commit 15fe452
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions vendor/assets/javascripts/foundation/jquery.foundation.tabs.js
@@ -1,11 +1,11 @@
(function ($) {

$.fn.foundationTabs = function (options) {

var settings = $.extend({
callback: $.noop
}, options);

var activateTab = function ($tab) {
var $activeTab = $tab.closest('dl').find('dd.active'),
contentLocation = $tab.children('a').attr("href") + 'Tab';
Expand All @@ -21,17 +21,17 @@
$(contentLocation).closest('.tabs-content').children('li').removeClass('active').hide();
$(contentLocation).css('display', 'block').addClass('active');
};
$('dl.tabs dd a', this).on('click.fndtn', function (event){

$(document).on('click.fndtn', 'dl.tabs dd a', function (event){
activateTab($(this).parent('dd'));
$(this).attr("href", window.location.pathname + $(this).attr("href").replace(/^.+#/, '#'));
});

if (window.location.hash) {
activateTab($('a[href="' + window.location.hash + '"]').parent('dd'));
settings.callback();
}

};

})(jQuery);

0 comments on commit 15fe452

Please sign in to comment.