2

我正在使用 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) {

});

感谢您的时间。

4

1 回答 1

1
survey.onCurrentPageChanging.add(function (sender, options) {
    if(survey.data.year === "1991") {
        // This prevents survey go to the next page
        options.allowChanging = false;
    }
});
于 2018-12-03T07:26:32.583 回答