javascript - jQuery SmartWizard 3.0 - goToStep method causes infinite loop -
i'm trying use jquery wizard smarteizard 3.0 has 'gotostep' method allowing jump given step based on logic. tried below code seems stuck in infinite loop , never goes next step. can spot i'm doing wrong here?
$(document).ready(function () { // smart wizard $('#wizard').smartwizard({ enablefinishbutton: false, onleavestep:onleavestepfunction, onfinish:onfinishcallback }); function onleavestepfunction(obj, context) { . . . //when below triggered, smartwizard gets stuck in infinite loop if ('#addprofilecheckbox').prop('checked')){ $('#wizard').smartwizard('gotostep',4); } return true; } function onfinishcallback(){ console.log('here ...'); } }); in chrome can see causing page crash , "stack limit exceeded' error.
this happens because onleavestepfunction() fired again when call $('#wizard').smartwizard('gotostep',4), causing infinite loop:
onleave -> gotostep -> onleave -> gotostep , on.
Comments
Post a Comment