Changing the hash but not moving the page using jquery ui tabs

后端 未结 3 520
庸人自扰
庸人自扰 2021-01-14 07:00

I added the following code to change the hash to the tab name:

$(\"#tabs > ul\").tabs({ 
select: function(event, ui){ 
window.location.hash = ui.tab.hash;         


        
3条回答
  •  情深已故
    2021-01-14 07:11

    You could try having a "return false;" after you set the window location but I can't be sure.

    Unfortunately, your problems won't end there. There are other issues with navigating back and forth across multiple browsers--nothing may change, page may reload, page state might be mangled, javascript may get reinitialized etc.

    You may want to have a look at Tabs v2 which uses the History/Remote plugin though it has not been updated for jQuery 1.3+.

    This demo is easier to understand. If you look at the javascript source, you'll notice the use of iframes to handle states.

    There is also the History Event plugin and the jHistory plugin to achieve what you want.

    Would like to hear back how things turns out and what solution you went with.

提交回复
热议问题