Redirect to Tab specifies

Asked

Viewed 192 times

-3

Good morning guys, I have a tab where I have a form that is sent via Ajax to my controller and I want that after the Ajax response the person is redirected to another tab after reloading the page, I need that when I click calculate the person go to Analysis Results someone can give me a light?

inserir a descrição da imagem aqui

Code of the GRT:

 <ul class="nav nav-tabs border-0 pt-5 data pt-sm-5 pt-md-1 mt-4 justify-content-center position-fixed mt-md-2 col-sm-12 col-md-12 ml-0 " style="z-index:1;font-size:100%;" id="myTab" role="tablist">
    <li class="nav-item data active">
        <a class="nav-link data active " id="data" data-toggle="tab" href="#DataInput" role="tab" aria-controls="Data Input" aria-selected="true">Data Input &nbsp; <i class="fa fa-angle-right"></i></a>
    </li>
    <li class=" bg-light ">
        <input class="button" onclick="calculate()" type="submit" name="" 
     value="Calculate" style="margin-top:5px;">&nbsp;
    </li>
    <li class="nav-item analise ">
        <a class="nav-link  analise" id="analise" data-toggle="tab" 
       href="#Analise" role="tab" aria-controls="Analysis Results " aria- 
       selected="true"><i class="fa fa-angle-right"></i>Analysis Results 
      &nbsp; </a>
    </li>
    <li class="nav-item ">
        <a class="nav-link " id="graphs" data-toggle="tab" href="#Graficos" 
      role="tab" aria-controls="Analysis Results " aria-selected="true"><i 
       class="fa fa-angle-right"></i>Graph &nbsp; </a>
    </li>

</ul>
  • Greetings Jeison. You may have noticed that [pt.so] follows the structure of questions and answers in which there is a clear distinction between both. What is question is in the question, what is answer is in the answer. So please avoid putting the solution in the question. If you were able to solve the problem and the solution has not yet been posted by another user, you can reply by placing it. It’s not wrong to answer your own question.

3 answers

1

Use the window.location.href = "http://seusite.com";

After the answer of your Ajax

1

I don’t know if I understand this right, but try this: In part .done(... from the ajax method after you redirect to that page.

if ($('#tabCalc').hasClass('show')) { // verifica se a tab esta sendo 
mostrada
  $('#tabCalc').removeClass('show'); // remove a class show da tab
  $('#tabAna').addClass('show');     // add Class show na tab desejada
}
// ou você pode tentar assim mais simples poem ao meu ver uma forma 
ruim ou vc verifica todas com if acimae faz isso :D
  $('#tab1').removeClass('show');
  $('#tab2').removeClass('show');
  $('#tab3').removeClass('show');
  $('#tab4').removeClass('show');
  $('#tabDesejada').addClass('show'); 

after editing the question new options can be seen as in the code below:

// Após o retorno do método Ajax para redirecionar para o local da pagina desejado
window.location.href = "http://index.html#Analise"; 
// ou forçar um click no elemando analise que tbm o levará para o local desejado
document.getElementById('analise').click();

There are probably better ways to do this. I hope this helps you now. because from what I understand the question is what you wanted

  • did not work, I will edit and leave the tab code, maybe it helps

  • you just want to set the tab selected or the contents of it tbm?

  • tries> window.location.href = "http://answall.com#Analyze"; < ps: sorry this probably won’t work maybe, but if you want it to be redirected to the side of the content that is on the page this will certainly serve if the content is not hidden. now if the content is cult and you are working with tabs and the click on 'Analyze Result' just go to the content you can try tbm > Document.getElementById('analyze'). click(); <;

  • modify the Aria-Controls="Analysis Results" of the graphs to the correct name with the same name as Parse Result. vo edit the answer. tbm

  • managed to solve simulating a click with java Script, I will update to leave registered, obg by help.

  • Good :D sorry I don’t have the best method, to help you .

Show 1 more comment

1


My problem has been solved as follows:

<a href="#" id="meuElemento" onclick="funcao('minha string')">clique aqui.</a>

    <script>
        function funcao(string) {
            alert(string)
        }
        document.getElementById("meuElemento").click();
    </script>

Browser other questions tagged

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