eduardotkoller/convForm

rollback and reset answers

Opened this issue · 3 comments

Diabz commented

Hi,
Thank you for sharing your work, your plugin is very cool and pleasant to use !

I have a bug when rollbacking to the first question fork and choosing another answer, the "new choice" is not stored and I'm stuck in the loop of the "first time choice"
Is it possible to rollback to the first question and reseting all the old answers stored ?

I know you're very busy at the moment but really apreciate if you can help me with that.
Thanks a lot !

Also stuck on this problem :(

We may leverage data-callback option on a question to cache and then reset state and answers.

<option name="firstQuestion" data-callback="cacheState">
<option name="resetQuestion" data-callback="rollback">

var rollbackTo = false;
var rollbackAnswers  = false;
function cacheState(stateWrapper, ready) {
  rollbackTo = stateWrapper.current;
  rollbackAnswers = { ...stateWrapper.answers };
}
function rollback(stateWrapper, ready) {
  if(rollbackTo) {
    stateWrapper.current.next = rollbackTo;
    stateWrapper.answers = { ...rollbackAnswers};
  }
}

Hello, I am on the same issue. Have you found any workaround ?