Change tabs through Modal bootstrap

Asked

Viewed 1,031 times

1

Thanks to our colleague Dontvotemedown, I can change the tabs through buttons through this solution tabs with jquery. But when I try to change the tabs by Bootstrap modal, I can’t. I have the following code:

  $(function() {
    $( "#tabs" ).tabs();

    $("#Sim").on("click", function() 
            {
          $( "#tabs" ).tabs();
          var indice = $('#tabs ul li a[href="#' + $(this).parent().prop("id") + '"]').parent().index();
          $("#tabs").tabs("option", "active", (indice + 1));
    });

("#Sim") is the button id, IE by Modal I ask if he wants to register another service, if he click on Yes, was to go to another tab:

<button type="button" class="btn btn-primary" id="Sim" data-dismiss="modal">Sim</button>

1 answer

1

I was able to solve it. The solution was as follows. The structure of the tabs is as follows:

 <div id="tabs">
  <ul>
    <li><a href="#tabs-1">Aba 1</a></li>
    <li><a href="#tabs-2">Aba 2</a></li>
    <li><a href="#tabs-3">Aba 3</a></li>    
    <li><a href="#tabs-4">Aba 4</a></li>
  </ul>

When I click the button Yes put the following code:

 $("#Sim").on("click", function() 
            {  
        var novaURL = "index.php?#tabs-2";
        $(window.document.location).attr('href',novaURL);    
});

Notice I put the #tabs-2 concerning Flap 2 and so on. .....

Browser other questions tagged

You are not signed in. Login or sign up in order to post.