jQuery UI tabs, update url when clicking on a different tab

前端 未结 8 825
甜味超标
甜味超标 2020-12-09 11:56

I\'m using the tabs of jQuery UI: http://jqueryui.com/demos/tabs/

How to update the current url of the browser when the user click on a different ta

8条回答
  •  醉话见心
    2020-12-09 12:18

    I had to use "create" instead of "activate" to get my initial tab to show in the URL:

        $('#tabs').tabs({
            create: function(event, ui) {
                window.location.hash = ui.panel.attr('id');
            }
        });
    

    This solution seems to be working for changing the URL, but when I go back to the URL it doesn't switch tabs for me. Do I have to do something special to make it switch tabs when that URL is hit?

提交回复
热议问题