0

I'd like to use jquery ui tabs plugin, but not have it changing the url hash when I click a tab.

I'm using a separate plugin for managing history, and it's screwing with it.

In other words, when I click a tab the content should change, but not the url hash

Any ideas?

The Docs are here, but it doesn't mention anything about this.

Edit : Thats weird, I'm not sure what was causing it to change the window hash. It's not occurring anymore though.

p3drosola
  • 5,784
  • 2
  • 23
  • 30
  • I don't notice any hash changes when using the example tab setups at the documentation site. – Pointy Jan 30 '12 at 16:32

3 Answers3

3

Having the same problem. Here you go!

// Prevent hashtag change on tab link click
$('.ui-tabs-nav a').live('click', function(e){
    e.preventDefault();
    e.stopPropagation();
});
emc
  • 507
  • 1
  • 7
  • 25
  • 1
    If this does not help, try adding "e.stopPropagation();" into the handler. It solved my problem. – Radek Pech Feb 25 '14 at 08:22
  • This did not work for me but it lead me to this which did https://stackoverflow.com/questions/8624531/preventing-scroll-when-using-uri-hash-to-identify-tab. There are a couple solutions there. One worked for me. – Willy Richardson Jun 24 '22 at 01:22
  • 10 years later it doesn't work? Not totally surprised :D – emc Sep 03 '22 at 16:56
1

http://jqueryui.com/demos/tabs/default.html

The url hash doesn't change for me. What plugin are you using for managing history?

Trav McKinney
  • 988
  • 8
  • 24
  • I'm using a custom plugin that listens for the window.hashchange event. But it doesn't interfere with anchors. – p3drosola Jan 30 '12 at 16:55
0

can you please try:

var currentHash = top.location.hash;

$('#example').bind('tabsshow', function(event, ui) {
   top.location.hash = currentHash;
}

i haven't tried it, i can't set up the environment here. It is possible that when you reset the hash, it doesn't behave as you wish...

André Alçada Padez
  • 10,987
  • 24
  • 67
  • 120