Skip to content

Instantly share code, notes, and snippets.

@albb0920
Created October 3, 2016 03:19
Show Gist options
  • Save albb0920/168b1ac97b90d863312997fa5ca4d379 to your computer and use it in GitHub Desktop.
Save albb0920/168b1ac97b90d863312997fa5ca4d379 to your computer and use it in GitHub Desktop.
bootstrap tab thing
$('#settings-tabs a[data-target]').click (e)->
e.stopPropagation()
e.preventDefault()
history.pushState(null, null, $(this).attr('href'))
$('#settings-tabs .active').removeClass('active')
$(this).closest('li').addClass('active')
active_pane = $($(this).data('target'))
active_pane.closest('.tab-content').find('.tab-pane.active').removeClass('active')
active_pane.addClass('active')
if tab = URI.parseQuery(URI().query())['tab']
$("#settings-tabs a[data-target=\"##{tab}\"]").click()
else
$('#settings-tabs a[data-target]').first().click()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment