0

I have couple of buttons in Tab2. Those buttons redirect the page1 to Page2. In Page2 I have link which redirect back to Page1. But when Page1 loads it showing tab1, not tab2. So how to remember tab2 here.

    var selected_tab = 1;
        $(function () {

            var handleSelect = function(e, tab) {

                var index = tab.newTab.index()
                if (index == 1) {
                    $("#divRightPanel").hide();
                    $("#divtabs").width("100%");
                } else {
                    $("#divRightPanel").show();
                    $("#divtabs").width("49%");
                }
            },
              tabOpts = {
                  beforeActivate : handleSelect
              };
            $("#tabs").tabs({ beforeActivate: handleSelect});

            $("form").submit(function () {
                $("[id$=selected_tab]").val(selected_tab);
            });
});

Edit: As post jquery ui tabs no longer supporting cookie? now what? It is remembering fine. But handleSelect is not firing where I am hiding div inside. any suggestions?

$( ".selector" ).tabs({
     beforeActivate: handleSelect,
    active   : $.cookie('activetab'),
    activate : function( event, ui ){
        $.cookie( 'activetab', ui.newTab.index(),{
            expires : 10
        });
    }
});
Community
  • 1
  • 1
James123
  • 11,184
  • 66
  • 189
  • 343
  • Near-duplicate of [Remember which tab was active after refresh](http://stackoverflow.com/questions/4299435/remember-which-tab-was-active-after-refresh) – mr_plum Apr 30 '14 at 19:10
  • @nunzabar Please updated posted. – James123 Apr 30 '14 at 19:44
  • Thanks; I didn't realize the cookie option was deprecated. Looks like you solved that and now have a different problem. Maybe it should be a new question. – mr_plum Apr 30 '14 at 20:14

0 Answers0