0

I am using jquery steps for a form wizard. Then I want the steps to have different forms, everytime step changes, with previous or next buttons, I d like to submit the form via ajax.

When i tried with multiple forms, it didnt work, cause var form = $("#example-advanced-form").show(); so i guess i cant use multiple forms?

Does that mean, I should submit the whole form everytime I change a step? Well i cant really do that, because in different steps there are validation rules on server side.

Can you help me out?

DarthVader
  • 52,984
  • 76
  • 209
  • 300

2 Answers2

0

Jquery steps might not be the right solution for you. If you have quite different forms to present based on the data provided, I think you have two options:

1) Do it in JavaScript. I'd probably caution against this because it would be exposing a lot of your business logic (if x then display y) in your javascript.

2) Use partial views (in MVC) based on the model that's being sent in. If I had something really complicated to work with, personally I'd rather have that in MVC land than in JavaScript, but that's a personal preference.

Eric
  • 2,273
  • 2
  • 29
  • 44
0

Add $('#wizard-p-'+currentIndex).submit() in onStepChanging and create submit function like this

$('#wizard-p-0').submit(function(e) { var $form = $(this); var postData = $(this).serializeArray(); var formURL = $(this).attr("action"); $.ajax({ url : formURL, type : "POST", data : postData, async : true, success : function(data) { //success code }, error : function(jqXHR,textStatus,errorThrown) { //error code } }); e.preventDefault(); }); }

This function is for submitting step-1. Make same functions for every relevant steps.

Half Blood Prince
  • 951
  • 2
  • 13
  • 25