Skip to content

Commit 7ad48a1

Browse files
committed
Update jquery.steps.js
- Add a fix for the fix before - Add a fix for the clickAction method (add the class disabled to the anchor again if the step changing event handler returned false)
1 parent 160fd4c commit 7ad48a1

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

js/jquery.steps.js

+20-9
Original file line numberDiff line numberDiff line change
@@ -324,13 +324,24 @@
324324
{
325325
var options = wizard.data("options");
326326
var state = wizard.data("state");
327+
var oldIndex = state.currentIndex;
327328

328329
if (index >= 0 && index < state.stepCount && !(options.forceMoveForward && index < state.currentIndex))
329330
{
330331
var anchor = $(".steps a[href$='-" + index + "']", wizard);
332+
var isDisabled = anchor.parent().hasClass("disabled");
333+
// Remove the class to make the anchor clickable!
331334
anchor.parent().removeClass("disabled");
332335
anchor.click();
333336

337+
// An error occured
338+
if (oldIndex == state.currentIndex && isDisabled)
339+
{
340+
// Add the class again to disable the anchor; avoid click action.
341+
anchor.parent().addClass("disabled");
342+
return false;
343+
}
344+
334345
return true;
335346
}
336347

@@ -573,12 +584,12 @@
573584

574585
if (options.enablePagination)
575586
{
576-
var finish = $(".actions a[href='#finish']", wizard);
577-
var next = $(".actions a[href='#next']", wizard);
587+
var finish = $(".actions a[href='#finish']", wizard).parent();
588+
var next = $(".actions a[href='#next']", wizard).parent();
578589

579590
if (!options.forceMoveForward)
580591
{
581-
var previous = $(".actions a[href='#previous']", wizard);
592+
var previous = $(".actions a[href='#previous']", wizard).parent();
582593
if (state.currentIndex > 0)
583594
{
584595
previous.removeClass("disabled");
@@ -611,22 +622,22 @@
611622
{
612623
if (state.stepCount == 0)
613624
{
614-
finish.parent().hide();
615-
next.addClass("disabled").parent().show();
625+
finish.hide();
626+
next.show().addClass("disabled");
616627
}
617628
else if (state.stepCount > 1 && state.stepCount > (state.currentIndex + 1))
618629
{
619-
finish.parent().hide();
620-
next.removeClass("disabled").parent().show();
630+
finish.hide();
631+
next.show().removeClass("disabled");
621632
}
622633
else if (!options.enableFinishButton)
623634
{
624635
next.addClass("disabled");
625636
}
626637
else
627638
{
628-
finish.parent().show();
629-
next.removeClass("disabled").parent().hide();
639+
finish.show();
640+
next.hide().removeClass("disabled");
630641
}
631642
}
632643
}

0 commit comments

Comments
 (0)