aidanlister / jquery-stickytabs

Provides persistant state (back and forward button support) for Bootstrap tabs
http://aidanlister.com/2014/03/persisting-the-tab-state-in-bootstrap/
MIT License
60 stars 33 forks source link

Keep path name on hashchange #9

Closed althaus closed 9 years ago

althaus commented 9 years ago

Hey,

I'm playing around with your nifty plugin to streamline some Bootstrap Tabs. I encountered an issue with the pathname on switching the tabs:

When I'm on a page like

http://example.org/foo/bar/page

containing tabs #foo and #bar switching a tab causes the browser to show

http://example.org/#foo
http://example.org/#bar

which isn't what I'd want. Changing L26 [1] from

history.pushState(null, null, '#' + hash);

to

history.pushState(null, null, window.location.pathname + '#' + hash);

fixes this for me and the browser shows the desired history updates:

http://example.org/foo/bar/page#foo
http://example.org/foo/bar/page#bar

Cheers Matthias

[1] https://github.com/aidanlister/jquery-stickytabs/blob/master/jquery.stickytabs.js#L26

aidanlister commented 9 years ago

Thanks, I've pushed 6d05378, let me know if that fixes your issue and thanks for providing the fix!

althaus commented 9 years ago

6d05378 works fine for me.