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