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