It now works before dom is ready :)

This commit is contained in:
Guillermo Rauch 2012-03-01 19:53:51 -03:00
parent 110765dbc1
commit bc178a5228

View File

@ -8,21 +8,22 @@
* 8/17/2011 * 8/17/2011
*/ */
jQuery(function ($) { (function ($) {
// hash change handler // hash change handler
function hashchange () { function hashchange () {
var hash = window.location.hash var hash = window.location.hash
, el = $('ul.tabs [href*="' + hash + '"]') , el = $('ul.tabs [href*="' + hash + '"]')
, content = $(hash)
if (el.length) { if (el.length && !el.hasClass('active') && content.length) {
$(el).closest('.tabs').find('.active').removeClass('active'); el.closest('.tabs').find('.active').removeClass('active');
$(el).addClass('active'); el.addClass('active');
content.show().addClass('active').siblings().hide().removeClass('active');
$(hash).show().addClass('active').siblings().hide().removeClass('active');
} }
} }
// listen on event and fire right away // listen on event and fire right away
$(window).on('hashchange.skeleton', hashchange); $(window).on('hashchange.skeleton', hashchange);
hashchange(); hashchange();
}); $(hashchange);
})(jQuery);