Keep jquery user interface tab even after form message

I use jQuery UI tabs where I have several forms within tabs. I want to keep the tab even after the form message .

I do not want to use cookie.js

You can see my code here, jsbin

How can I achieve this using another method?

thank

+3
source share
2 answers

The easiest way is to submit ajax to the form. Something like this will do:

$("form").submit(function() {
  $.post(); // do the necessary post here
  return false; // Do not submit the form
});

If you are not allowed to use Ajax, you can pass the tab information to the URL:

<div id="fragment-1">
    <p>Form 1</p>
    <form method="post" action="?tab=1">
      <input type="text" value="">
      <input type="submit" value="Save Changes" />
    </form>
</div>

:

$("#tabs").tabs("select", tab);

- this, javascript.

+2

, , .

<script type="text/javascript">
 $(document).ready(function () {
                $('#tabs').tabs({
                    select: function (event, ui) {
                        $("#<%= hfSelectedTAB.ClientID %>").val(ui.index);
                    }
                });
                $("#tabs").tabs("option", "selected", [$("#<%= hfSelectedTAB.ClientID %>").val()]);
            });
</script>

 <asp:HiddenField ID="hfSelectedTAB" runat="server"  Value="0"/>

Simple. .

+2

Source: https://habr.com/ru/post/1792232/


All Articles