I am using a bootstrap modal steps plugin stepwise
I've populated the steps per the docs with my form fields (truncated):
<div class="modal-body">
<div class="row hide" data-step="1" data-title="This is the first step!">
<form method="post" action="">
<input type="text" id="name" name="name" class="form-control">
</form>
</div>
<div class="row hide" data-step="2" data-title="This is the second and last step!">
<form method="post" action="">
<input type="text" id="email" name="email" class="form-control">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default js-btn-step pull-left" data-orientation="cancel" data-dismiss="modal"></button>
<button type="button" class="btn btn-warning js-btn-step" data-orientation="previous"></button>
<button type="button" class="btn btn-success js-btn-step" data-orientation="next"></button>
</div>
</div>
Then initialise:
var callback = function (){
console.log('Congratulations!');
//get all form fields data here or call the save function with parameters
};
$('#modal-sample').modalSteps({
completeCallback: callback
});
How can I get the data of the form on the final callback? I can use javascript and get the field data by id/class on each steps callback but that's a bit hacky. Ideally would like to call a function on the final step and pass some parameters in it. Because the next button is dynamic and becomes the final complete button I am not able to inject any function calls to it.
If I could add a onclick event on the final submit button then that would be better.
On the final step the data-orientation="next" becomes: data-orientation="complete"
Not very familiar with using callbacks, they mention validating fields on each step so I assume there is a way to check all fields but I am not sure how. Any help highly appreciated.