Run code on tabshow or stepchange

  • 1
  • Question
  • Updated 3 years ago
  • Answered
Does something like this work to run code on the 'tabshow' and wizard 'stepchange' events?

                $('body')
                .on('tabshow', function(){
                    component.loadevent();
                })
                .on('stepchange', function(){
                    component.loadevent();
                });

Is there a better way to write that?
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Update: This seems to work, but calls loadevent() once for each step of a wizard that has been loaded. When I click to step two, it calls loadevent() twice, when I click to step three, it calls loadevent() three times. Any idea why that would be occurring?
Photo of Moshe Karmel

Moshe Karmel, Champion

  • 8,646 Points 5k badge 2x thumb
Matt check this out : https://community.skuidify.com/skuid/topics/step_onload_event_or_wizard_onnavigate_event
The key is to add the 2 parameters into your function (e and data). You can just log them to see what information you have access to on every event. Then use some logic to filter out when your actions will run.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Moshe,

Yes, that post is where I found the 'stepchange' event to begin with. My initial question was whether I could call 'stepchange' from $('body') instead of specifying a jquery selector for the wizard itself (trying to be as generic as possible). That seems to work, although it seems to fire once for each step that has been loaded.
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Actually... I figured it out. I'm running this code from a custom component, and I have a different version of the component on each step of the wizard, so it is just running once for each component.

Solved! :)
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Super!