Wizard (asp.net mvc) how to get the from where which step the user came

1 Answer 172 Views
Wizard
Azhar
Top achievements
Rank 1
Iron
Azhar asked on 30 Jul 2021, 04:52 AM

Let us say the a wizard has 5 steps.
Where user goes from step 2 -> step 3, I want to do some activity.
Currently I use e.step.options.index inside onSelect  method to do that.


function onSelect(e) {
    if (e.step.options.index == 3) {
       //do something
    }
}

 

The problem is the "//do something" is also executed when user comes to step 3 from step 4 (step 4 -> step 3).
I do NOT want this to happen. I want to prevent this from happening.

How do I do it?

How do I know which step the user came from?

1 Answer, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 03 Aug 2021, 04:01 PM

Hello Azhar,

Here's how you can get the previously selected step's index and use this information to execute your logic only when the user navigates to step 3 from a step with lower index (e.g., 2 to 3):

function onSelect(e) {
  var previousIndex = e.sender.activeStep().options.index;
  var currentIndex = e.step.options.index;

  if (currentIndex == 3 && currentIndex > previousIndex) {
    //do something
  }
}

 

Regards,
Ivan Danchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Wizard
Asked by
Azhar
Top achievements
Rank 1
Iron
Answers by
Ivan Danchev
Telerik team
Share this question
or