lundi 23 mars 2015

Bootstrap tabs go to specific tab on same page after form submit

I have looked at many different threads on here about this issue, but none exactly answered my question.


I have a form, on tab 2. Once I submit that form, the page reloads and I'm back at tab 1. I need it to go back to tab 2 after the form submits.


This jsfiddle shows how you can use a link to jump from tab to tab on the same page, but how would I implement it into a form? http://ift.tt/1sbjcqB


It uses this function:



$("a[data-tab-destination]").on('click', function() {
var tab = $(this).attr('data-tab-destination');
$("#"+tab).click();
});


Another popular link: Twitter Bootstrap Tabs: Go to Specific Tab on Page Reload or Hyperlink


But the solutions from that link are only if your going to another page, and do not work on the same page. And I still wouldn't know how to implement that into a form.


I tried



<form action"javascript:function()">...</form>


and had a function that accomplished what I needed, but javascript doesn't work in the action attribute all that well.


How can I achieve this?


EDIT: After going through the bootstrap documentation, I still have not found a solution to my problem. To restate, I need to go to a tab that is not the primary or active tab after you submit a form.


Aucun commentaire:

Enregistrer un commentaire