API 使用 SurveyJS 调用和导航控件
API call and Navigation controls with SurveyJS
我正在使用 SurveyJS (https://surveyjs.io/) 制作一个几乎没有问题的简单网站。我可以使用 SurveyJS 提供的选项执行所有逻辑。
但是,我想要做的是:
- 在其中一个问题 之后进行 API 调用(按预期工作)
- 等待 API 调用,然后再转到下一个问题 (按预期工作)
- 如果 API 回答
false
,请不要转到下一个问题。 (不工作)
无论我做什么,调查都会继续转到下一个问题,我想在这种情况下避免这种情况。
可用的三个回调:
// triggers before the current page goes away
survey.onCurrentPageChanging.add(function (sender, options) {
if(survey.data.year === "1991") {
// let's say I want to stop user from going forward at this point.
// how can I do that?
}
});
// triggers after the current page is gone and new page is about to appear
survey.onCurrentPageChanged.add(function (sender) {
});
// triggers right before the survey is about to finish - the last page
survey.onCompleting.add(function (sender, options) {
});
感谢您的宝贵时间。
survey.onCurrentPageChanging.add(function (sender, options) {
if(survey.data.year === "1991") {
// This prevents survey go to the next page
options.allowChanging = false;
}
});
我正在使用 SurveyJS (https://surveyjs.io/) 制作一个几乎没有问题的简单网站。我可以使用 SurveyJS 提供的选项执行所有逻辑。
但是,我想要做的是:
- 在其中一个问题 之后进行 API 调用(按预期工作)
- 等待 API 调用,然后再转到下一个问题 (按预期工作)
- 如果 API 回答
false
,请不要转到下一个问题。 (不工作)
无论我做什么,调查都会继续转到下一个问题,我想在这种情况下避免这种情况。
可用的三个回调:
// triggers before the current page goes away
survey.onCurrentPageChanging.add(function (sender, options) {
if(survey.data.year === "1991") {
// let's say I want to stop user from going forward at this point.
// how can I do that?
}
});
// triggers after the current page is gone and new page is about to appear
survey.onCurrentPageChanged.add(function (sender) {
});
// triggers right before the survey is about to finish - the last page
survey.onCompleting.add(function (sender, options) {
});
感谢您的宝贵时间。
survey.onCurrentPageChanging.add(function (sender, options) {
if(survey.data.year === "1991") {
// This prevents survey go to the next page
options.allowChanging = false;
}
});