Bootstrap Tour无法启动

时间:2014-05-09 16:11:44

标签: jquery bootstrap-tour

我在我的网站上以及 this fiddle 中设置了以下非常简单的演示。它与 the official demo 几乎完全相同。在这两种情况下我都不会参观。我错过了什么?

<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.8.1/css/bootstrap-tour.min.css"> 
<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">

<script type='text/javascript' src='http://code.jquery.com/jquery-git.js'></script>
<script type='text/javascript' src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script type='text/javascript' src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.8.1/js/bootstrap-tour.min.js"></script>

<button class="btn" id="tour-go">Start the tour!</button>

<form>
    <input id="one" value="one" />
    <input id="two" value="two" />
    <input id="three" value="three" />
</form>

$(function () {
    var tour = new Tour({
        steps: [{
            element: "#one",
            title: "Title of my step",
            content: "Content of my step"
        }, {
            element: "#two",
            title: "Title of my step",
            content: "Content of my step"
        }, {
            element: "#three",
            title: "Title of my step",
            content: "Content of my step"
        }]
    });

    // Initialize the tour
    tour.init();

    $('#tour-go').click(function () {
        // Start the tour
        tour.start();
    });
});

4 个答案:

答案 0 :(得分:4)

您正在使用bootstrap-tour v0.8.1,因此您的代码不正确,正确的代码是:

var tour = new Tour() ;

tour.addSteps([{
    element: "#one",
    title: "Title of my step",
    content: "Content of my step"
}, {
    element: "#two",
    title: "Title of my step",
    content: "Content of my step"
}, {
    element: "#three",
    title: "Title of my step",
    content: "Content of my step"
}]) ;

这个小提琴正在起作用:http://jsfiddle.net/9LcQx/

答案 1 :(得分:3)

your fiddle

替换你的js
$(function () {
    var tour = new Tour();
    tour.addStep({
      element: "#one",
      title: "Step 1",
      content: "Content for step 1"
    });

    tour.addStep({
      element: "#one",
      title: "Step 2",
      content: "Content for step 2"
    });

    tour.addStep({
      element: "#three",
      title: "Step 3",
      content: "Content for step 3"
    });
    // Initialize the tour
    tour.init();

    $('#tour-go').click(function () {
        // Start the tour
        tour.start();
    });
});

答案 2 :(得分:0)

您的错误是使用 steps 。但是正确的是你必须使用 tour.addStep 来完成这项工作。

检查此 Demo js Fiddle

的jQuery

var tour = new Tour();

tour.addStep({
        element: "#one",
        title: "Title of my step",
        content: "Content of my step"
    });
tour.addStep({
        element: "#two",
        title: "Title of my step",
        content: "Content of my step"
});
tour.addStep({
        element: "#three",
        title: "Title of my step",
        content: "Content of my step"
});

// Initialize the tour
tour.init();

$('#tour-go').click(function () {
    // Start the tour
    console.log("Click");
    tour.start();
});

答案 3 :(得分:0)

我尝试了以上所有提出的解决方案但仍无法使其正常工作,所以我在网上发现一篇文章说,现有的bootstrap用户 NOT 应该使用{ {1}}。相反,他们应该使用bootstrap-tour-standalone.min.js

另外,请确认您使用的是适当版本的bootstrap。 “弹出窗口”并没有在我的情况下显示我切换到

boostrap-tour-min.js