thecodemine / formwizard

jQuery plugin based on top of jQuery UI which turns a form into a multistep wizard. Integrates with the jQuery form plugin for AJAX submission of the form, the validation plugin for client side validation and the BBQ plugin for enabling the browsers back and forward buttons.
140 stars 54 forks source link

after submit step? #27

Closed rigond closed 12 years ago

rigond commented 12 years ago

Is it possible to add an after_submit step to the formwizard to perhaps show a success message and a close button?

thecodemine commented 12 years ago

Hi,

I assume that you are sending the form using ajax? If so, you can use the success callback function to take care of hiding the wizard and showing a success message (and close button). If you specifically need to show another step in the wizard when the form is successfully posted, just call e.g. $("#demoForm").formwizard("show", "success_step"); in the success callback.

e.g.

            $(function(){
                $("#demoForm").formwizard({ 
                    formPluginEnabled: true,
                    validationEnabled: true,
                    focusFirstInput : true,
                    formOptions :{
                        success: function(data){
                            $("#demoForm").formwizard("show", "success_step");
                        },
                        beforeSubmit: function(data){$("#data").html("data sent to the server: " + $.param(data));},
                        dataType: 'json',
                        resetForm: true
                    }   
                 }
                );
        });

You can probably find suitable documentation for the show method etc at http://thecodemine.org/

Would this work for you?

rigond commented 12 years ago

Thanks for the quick reply! Yes I'm posting the form with ajax on each step. In the final step I summarise the form then submit it.

I would like to show a 'success_step' after submitting the form. I've tried your method above but, the formwizard counts the 'success_step' as the last step of the form and thus renders the submit button in the 'success_step' and not the step before.

thecodemine commented 12 years ago

Hi,

try adding the class="submit_step" to the step that should submit the form (thus the last step before the success_step)

Hope this should take care of it.

rigond commented 12 years ago

Yes this worked. Thank you very much!