John Smith
John Smith

Reputation: 6197

jQuery, is there a way to set anchor in URL after form submitting?

For example, I have tabulators (bootstrap, tabpanel) which changes the url, adding #tab1, #tab2, ... as Im clicking on them. Lets say I do a submit from #tab1, and want to jump to #tab2, how to do that? All I have is:

.
.
.
$(formObj).submit();
return false;

the action of form is empty (<form method="post">)

Upvotes: 1

Views: 76

Answers (1)

Alvaro Montoro
Alvaro Montoro

Reputation: 29655

You could use the .tab("show") function, as specified in the Bootstrap documentation, to show the tab that you want after the form submission.

For example, if your form is in #tab1 and you want to move to #tab2 after the form is submitted, you could do it like this (change #myTabs for the id of the tab list that you are using):

$(formObj).submit();
$('#myTabs a[href="#tab2"]').tab('show')
return false;

Upvotes: 1

Related Questions