Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy/initiate issue #35

Closed
outprove opened this issue Mar 2, 2015 · 8 comments
Closed

Destroy/initiate issue #35

outprove opened this issue Mar 2, 2015 · 8 comments

Comments

@outprove
Copy link

outprove commented Mar 2, 2015

If I alternatively destroy a wizard and then initiate it, after doing so subsequent initializations cause odd behavior. Instead of showing one branch at a time, it shows n+1 branches. (So the second time it's initialized, it shows two branches for each "forward", the next time it's destroyed/initialized it shows three, etc....) Obviously something is not being reset properly in the destroy logic, but I havent yet figured out what/where it is. Any ideas?

By the way, thank you for such a useful piece of code.

ETA: Here's a jsfiddle of a subset of the page we're using, you can see the behavior by stepping through the wizard a little bit, turning off the interview (destroying the wizard) and then turning it back on , and then stepping through it again.: http://jsfiddle.net/y0w1mmkh/22/

@kflorence
Copy link
Owner

@outprove Thanks for reporting. I will take a look when I have some free time.

@kflorence
Copy link
Owner

@outprove I looked at the JSFiddle example briefly and I noticed several problems, although I don't see how any of them could cause the behavior you're experiencing:

  • you don't need to apply any wizard-* classes yourself -- the plugin will take care of this for you.
  • not every step needs to have it's own branch. the wizard itself is the default branch, so steps can just be children of the wizard (unless branches are needed).
  • by default, the wizard will transition to the data-state provided -- so you don't need to manually provide all of those transitions yourself. If you want to make sure the .val() of the current step is not blank before proceeding, you can do that once in the beforeForward event handler.

@kflorence
Copy link
Owner

It will be difficult to try to reproduce this case outside of that JSFiddle since there is so much stuff going on. If anyone can reproduce this using a unit test, that would be preferable.

@outprove
Copy link
Author

@kflorence I'm actually using a database procedure to dynamically genereate the JS/HTML based on a user-customizable questionnaire. (Hence the excessive branches/transitions for every question, I never know what I'll need in terms of complexity of dependencies ). I'll attempt to reproduce with a stripped down test.

@outprove
Copy link
Author

I simplified it, I simply used the first included example (and stripped it to the first one at that.) Here's the jsfiddle:

https://jsfiddle.net/ed1rb2fr/17/

To reproduce it:

  1. Start the wizard by clicking on the button
  2. Enter a value in name, and hit forward
  3. At the second step hit destroy wizard
  4. Click startwizard again, the first step shows again properly
  5. Hit forward

You'll see then instead of just the second step, you'll see the second step and the result shown together. This doesnt happen during the first pass of the wizard if you dont destroy it.

Thanks!

@kflorence
Copy link
Owner

@outprove thanks for taking the time to do that, sorry I've been so busy, haven't had time to take a look yet. Perhaps I can get to it this weekend.

@outprove
Copy link
Author

@kflorence FYI, I figured out what the issue was - for some reason if you destroy and then reinstitute the wizard, the click event gets added again. I added a step in the destroy function that specifically unbinds the click event for both forward and backward:
( jQuery(self.elements.forward).off("click");
jQuery(self.elements.backward).off("click");)

That seemed to do the trick.

@kflorence
Copy link
Owner

@outprove thanks for digging into it. Sorry that I haven't had time to be more responsive. It sounds like this might be something that can be patched in the code. I'll take a look when I get the chance.

kflorence added a commit that referenced this issue Mar 26, 2017
#35: Remove bound events on .destroy().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants