Search code examples
javascripthtmlcsstwitter-bootstrapbootstrap-tour

Bootstrap Tour Not Working


I am testing out Bootstrap Tour for a very simple test page that I have setup. The content displays but the tour functionality does not kick in for some reason. Could someone tell me what I could be doing wrong?

Thanks :)

Please find my code attached below

<html>

<head>
    <meta charset="utf-8">
    <title> This is a testing page for bootstrap tour </title>

    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="../bootstraptour/build/css/bootstrap-tour.min.css" rel="stylesheet">
    <link href="../bootstraptour/build/css/bootstrap-tour-standalone.min.css" rel="stylesheet">

</head>


<!-- Bootstrap core JavaScript
  ================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="../bootstrap/js/jquery.min.js"></script>
<script src="../bootstrap/js/bootstrap.min.js"></script>
<script src="../bootstraptour/build/js/bootstrap-tour.min.js"></script>
<script src="../bootstraptour/build/js/bootstrap-tour-standalone.min.js"></script>

<script>
    var tour = new Tour();

    // Add your steps. Not too many, you don't really want to get your users sleepy
    tour.addSteps([{
        element: "#content", // string (jQuery selector) - html element next to which the step popover should be shown
        title: "Title of my step", // string - title of the popover
        content: "Content of my step" // string - content of the popover
    }, {
        element: "#content1",
        title: "Title of my step",
        content: "Content of my step"
    }]);

    // Initialize the tour
    tour.init();

    // Start the tour
    tour.start();
</script>


<body>
    <div id="content">
        Hello, World!
    </div>
    <br>
    <br>
    <br>
    <div id="content1">
        Another Hello, World!
    </div>
</body>

</html>

Solution

  • You should include either bootstrap-tour.min.css/bootstrap-tour.min.js (when you are including bootstrap.min.css/bootstrap.min.js yourself) or bootstrap-tour-standalone.min.css/bootstrap-tour-standalone.min.js, but not both. See the explanation on the bootstrap tour homepage.

    Here is a working snippet:

    var tour = new Tour();
    
    // Add your steps. Not too many, you don't really want to get your users sleepy
    tour.addSteps([{
      element: "#content", // string (jQuery selector) - html element next to which the step popover should be shown
      title: "Title of my step", // string - title of the popover
      content: "Content of my step" // string - content of the popover
    }, {
      element: "#content1",
      title: "Title of my step",
      content: "Content of my step"
    }]);
    
    // Initialize the tour
    tour.init();
    
    // Start the tour
    tour.start();
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.11.0/js/bootstrap-tour-standalone.min.js"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.11.0/css/bootstrap-tour-standalone.min.css" rel="stylesheet"/>
    
    <div id="content">
      Hello, World!
    </div>
    <br>
    <br>
    <br>
    <div id="content1">
      Another Hello, World!
    </div>