应用程序向导没有第二次显示卡的内容?

时间:2015-08-11 08:40:12

标签: jquery angularjs twitter-bootstrap

您好我正在使用bootstrap应用程序向导。当我第二次加载向导时,卡未初始化并且内容消失了。下面是我的代码。我正在使用bootstrap 3.3.5和Jquery 2.1.4 min版本。

在控制器中

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();
    });

1 个答案:

答案 0 :(得分:1)

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

在修改API之后,我能够使用上一个链接讨论的引用来解决这个问题。

            //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页面上的多张牌。如果用户没有刷新页面,向导将再次初始化,但长度现在将为零。该引用只是将向导初始化为原始卡数。

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

//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()添加到close事件中。