eduardotkoller / convForm

A jQuery plugin that transforms a form into an interactive chat.
https://eduardotkoller.github.io/convForm
MIT License
182 stars 108 forks source link

rollback and reset answers #57

Open Diabz opened 5 years ago

Diabz commented 5 years ago

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 !

ekunitsa commented 5 years ago

Also stuck on this problem :(

pjammula commented 3 years ago

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};
  }
}
hugodemenez commented 3 years ago

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