首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >申请向导没有第二次显示卡片的内容?

申请向导没有第二次显示卡片的内容?
EN

Stack Overflow用户
提问于 2015-08-11 08:40:11
回答 1查看 250关注 0票数 0

嗨,我正在使用引导应用程序向导。当我第二次加载向导时,卡片没有初始化,内容也消失了。下面是我的密码。我使用的是引导3.3.5和jQuery2.1.4min版本。

在控制器中

代码语言:javascript
复制
var wizard = $('#some-wizard').wizard({});
    $.fn.wizard.logging = true;
    $event.preventDefault();

    wizard.show();
    wizard.on("submit", function(wizard){
        $scope.agent = [];
        console.log("Inside submit");
        //console.log($scope.monitor);
        $scope.agent.agentId = id;
        $scope.agent.title = $("#title").val();
        $scope.agent.desc = $("#description").val();
        $scope.agent.userIds =  $rootScope.tselected;


        homeService.updateAgent($scope.agent).then(function(response) {
            if(response.sucess == 'true'){
                alert("success");
            }
            else {
                alert("Failed");
            }
        });
        wizard.submitSuccess();
                wizard.hideButtons();
                wizard.updateProgressBar(0); 
    });

    console.log("Monitor edited" + id);

    wizard.on('closed', function() {
                $('.modal-backdrop').remove();
                wizard.setActiveCard('card1');
            });

    wizard.el.find(".wizard-success .im-done").click(function() {
        wizard.reset();

        wizard.hide();
    });

    wizard.el.find(".wizard-success .create-another-server").click(function() {
        wizard.reset();
    });
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-08-18 15:13:34

我遇到了同样的问题。我也发现了这个:Bootstrap application wizard content dissapears,但它仍然让我有点困惑。

在对API做了更多修改之后,我能够使用前面的链接讨论的引用来修复这个问题。

代码语言:javascript
复制
            //Initialize Wizard
            var wizard = $("#environment-add-template").wizard(options);


            //If the page is not refreshed, this maintains the reference for multiple environment adds
            if (wizard._cards.length != 0) {
                wizardReference(wizard);
            } else {
                wizard = wizardReference();
            }

我使用的是knockout.js,因此wizardReference (向导)与wizardReference=向导相同。此外,每当用户按下事件按钮来启动向导时,wizard._cards.length将等于您在html页面上有多少张卡片。如果用户不刷新页面,向导将再次初始化,但长度现在为零。引用只是将向导初始化回原来的卡片数量。

这将使原始值带回来。如果要重置值,则必须添加如下内容:

代码语言:javascript
复制
//When the user submits the data or closes the wizard, this reverts all values to original state
            wizard.on("reset", function () {
                wizard.modal.find(':input').val('').removeAttr('disabled');
                wizard.modal.find(':select').val('').removeAttr('disabled');
                wizard.modal.find(':textarea').val('').removeAttr('disabled');
            });

只需将wizard.reset()添加到关闭事件中即可。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31937041

复制
相关文章

相似问题

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