2

我在使用 jQuery Step Wizard 插件动态创建一些步骤时遇到了一些麻烦。

这是我的代码:

<!DOCTYPE html>
<html>
    <head>
        <title>Demo</title>
        <meta charset="utf-8">

        <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
        <script>window.jQuery || document.write('<script src="js/jquery-1.10.2.min.js"><\/script>')</script>
        <script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js" type="text/javascript"></script>
        <script>$.mobile || document.write('<script src="js/jquery.mobile-1.4.0.min.js"><\/script>')</script>

        <script src="scripts/libs/modernizr-2.6.2-respond-1.1.0.min.js"></script>
        <script src="scripts/libs/jquery.steps-1.0.4.js"></script>
        <script src="scripts/libs/jquery.validate-1.11.1.min.js"></script>  

    </head>
    <body>
        <script>

            $(document).ready(function () {
                $("#wizard").steps();

                var wizard = $("#wizard").steps();
                wizard.steps("add", {
                    title: "HTML code", 
                    content: "This is a test"
                });
                wizard.steps("add", {
                    title: "HTML code2", 
                    content: "This is a test2"
                });                 
            });

        </script>
        <div id="wizard"></div>
    </body>
</html>

运行此页面时,网页上显示的只是“下一个”和“上一个”,但根本没有步骤。

我得到的控制台错误是这样的:

SCRIPT5022:缺少一个或多个相应的步骤标题。jquery.steps-1.0.4.js,第 1252 行字符 5

我能帮上忙吗?

提前致谢

4

2 回答 2

5

看起来您需要在调用中包含一些内容$('#wizard').steps();

基本的例子

$("#wizard").steps("add", {
  title: "Step Title",
  contentMode: "async",
  contentUrl: "data.xml"
});

尝试将您的更改为

$(function () {

  $('#wizard').steps("add", {
    title: "HTML code", 
    content: "This is a test"
  })

  .steps("add", {
    title: "HTML code2", 
    content: "This is a test2"
  });                 

});
于 2014-02-03T02:20:39.947 回答
1

更新代码

 $(document).ready(function () {
        ***$("#wizard").steps();***    //remove this line from your code

        var wizard = $("#wizard").steps();
        wizard.steps("add", {
            title: "HTML code", 
            content: "This is a test"
        });
        wizard.steps("add", {
            title: "HTML code2", 
            content: "This is a test2"
        });                 
    });
于 2014-02-03T05:20:00.100 回答