Selecting a jQuery Tab using a parameter in the URL

前端 未结 5 969
太阳男子
太阳男子 2020-12-02 23:35

I am currently investigating replacing the tabs provided by a Struts 1 tag library with the tabs provided by jQuery UI. I have successfully managed to get the tabs integrate

5条回答
  •  一生所求
    2020-12-03 00:12

    Jquery-UI give you that for (almost) free : Use the internal links. And it's better than using ugly get parameters.

    Passing http://my.site.org/mypage/#foo-tab in your navigator will automaticly select the tab with the container having id="foo-tab".

    The trick is to add an event to update the url when selecting a tab so that when you reload you do not lose the current tab :

       $(document).ready(function () {
            $("#tabs").bind('tabsselect', function(event, ui) {
                window.location.href=ui.tab;
            });
        });
    

提交回复
热议问题