Fix bug with stale "currentPage" with new SurveyJS plugin

This commit is contained in:
Ramon Wenger 2022-11-23 15:47:26 +01:00
parent 40f0f1cfb8
commit 7b4efca096
1 changed files with 11 additions and 2 deletions

View File

@ -55,6 +55,7 @@
data() {
return {
survey: this.initSurvey(),
currentPage: null,
surveyData: null,
title: '',
module: {},
@ -99,8 +100,8 @@
};
},
answers() {
return this.survey.currentPage && this.survey.currentPage.elements
? this.survey.currentPage.elements.reduce(extractSurveySolutions, [])
return this.currentPage && this.currentPage.elements
? this.currentPage.elements.reduce(extractSurveySolutions, [])
: [];
},
isTeacher() {
@ -129,6 +130,13 @@
survey.data = flatAnswers;
}
this.currentPage = survey.currentPage;
const updatePage = (sender, {oldCurrentPage, newCurrentPage}) => {
console.log(oldCurrentPage, newCurrentPage);
this.currentPage = newCurrentPage;
};
const saveSurvey = (sender, {exit}) => {
if (this.saveDisabled) {
return;
@ -192,6 +200,7 @@
});
});
survey.onCurrentPageChanged.add(saveSurvey);
survey.onCurrentPageChanged.add(updatePage);
survey.css = css;
survey.locale = 'de';