首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用SurveyJS的API调用和导航控件

使用SurveyJS的API调用和导航控件
EN

Stack Overflow用户
提问于 2018-12-03 06:19:57
回答 1查看 979关注 0票数 2

我正在使用SurveyJS (https://surveyjs.io/)创建一个简单的站点,很少有问题。我能够用SurveyJS提供的选项来完成我的所有逻辑。

然而,我想做的是:

  • 在其中一个问题之后进行API调用(按预期工作)
  • 在进入下一个问题之前等待API调用(按预期工作)
  • 如果API响应false**,,则不要移动到下一个问题。_(不工作)**_

无论我做什么,调查都会继续转到下一个问题,在这种情况下,我想避免这样做。

有三个可用的回调:

代码语言:javascript
复制
// 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) {

});

谢谢您抽时间见我。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-12-03 07:26:32

代码语言:javascript
复制
survey.onCurrentPageChanging.add(function (sender, options) {
    if(survey.data.year === "1991") {
        // This prevents survey go to the next page
        options.allowChanging = false;
    }
});
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53588462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档