0

I want my jquery UT tab to remember last tab to be the default one after formsubmit/page refresh and so on, my curent html code for this looks like this:

I have not found a awnser to this that actually work, so awnsers are welcome.

<div class="row">   
    <div class="col-md-12">
        <div class="tab-base">
            <!--Nav Tabs-->
            <ul class="nav nav-tabs">
                <li class="active">
                    <a data-toggle="tab" href="#demo-lft-tab-1">Tab1</a>
                </li>
                <li>
                    <a data-toggle="tab" href="#demo-lft-tab-2">Tab2</a>
                </li>
                <li>
                    <a data-toggle="tab" href="#demo-lft-tab-3">Tab3</a>
                </li>
            </ul>
            <!--Tabs Content-->
            <div class="tab-content">
                <div id="demo-lft-tab-1" class="tab-pane fade active in">
                    //somthimg here
                </div>
                <div id="demo-lft-tab-2" class="tab-pane fade">
                    //somthimg here
                </div>
                <div id="demo-lft-tab-3" class="tab-pane fade">
                    //somthimg here
                </div>
            </div>
        </div>
    </div>
</div>  

My js script: but this does not work after formsubmit / or move to another page and then back.

   $('a[data-toggle="tab"]').click(function(e) {
        var hash = $(this).attr('href');
        location.hash = hash;
    });
    $(function() {
        var hash = window.location.hash;
        var $nav = $('ul.nav a[href="' + hash + '"]');
        hash && $nav.trigger('click');
    });
sdfgg45
  • 1,232
  • 4
  • 22
  • 42

0 Answers0