I have a problem with jquery steps plugin.
I created 3 steps; the first is a presentation, the second there'is a form and third is a section for result's form.
<script>
function hasClass(element, cls) {
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
}
$("#example-async").steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "slide",
onFinished: function (event, currentIndex) {
},
labels: {
finish: "Register",
next: "Next",
previous: "Back",
loading: "Loading ..."
},
enableFinishButton: false,
saveState: true,
onStepChanging: function(event, currentIndex, newIndex)
{
var move = true;
if (currentIndex == 1) { // form
move = false;
var values = {};
$.each($('#UserRegisterForm input'), function(i, field) {
values[field.name] = field.value;
});
$.ajax({
type: 'POST',
url: "/cakephp/ajax/register_user",
data: JSON.stringify(values) ,
contentType: "application/json",
dataType: 'json',
success: function (data) {
if (data.result === 'ok')
{
move = true;
$("#example-async").steps("setStep", 2);
} else {
move = false;
}
}
});
}
return move;
}
});
When I click on button Next into 2section, i call a perl script and if var "result" is equal "ok" I changed section, else i return error into form. But when I click on button Next, my step does not change!
I have implemented too function into jquery.step. I add a function:
$.fn.steps.setStep = function (step) {
return _goToStep(this, getOptions(this), getState(this), step); };
And:
function _goToStep(wizard, options, state, index){
return paginationClick(wizard, options, state, index); }
Where I wrong?