Solved

Submit form to new jquery tab

Posted on 2014-09-12
2
295 Views
Last Modified: 2014-09-13
Hello,
We need to open a new jquery tab programmatically when submitting a form :
Let's say we have tab-1 with a form inside. When we submit the form, a new tab opens, tab-2, with the result of the form. Both tab-1 and tab-2 are loaded in ajax, so we kind of need to "convert" :
append(data).tabs('add', curLink, curName)
to a submit
Is it possible ?
0
Comment
Question by:javilmer
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40320349
$("#tab1 form").submit(function(evt) { // when submitting form in tab1
    evt.preventDefault(); // needed to prevent submit of the form and reload/change page
    $.post("/path/to/server/page.ext", $(this).serializeArray(), function(resultOfTheForm) { // assuming form use POST else replace by $.get
           $("#tab-2 div.content").html( resultOfTheForm ); // fill tab2 with result
           $( "#tabs" ).tabs( "option", "active", 2 ); // set tab 2 active
    });
});

Open in new window

0
 

Author Closing Comment

by:javilmer
ID: 40320717
great thanks !
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question