I am using bootstrap tour for a page tour. What I want to do is to start the tour automatically once you visit the page, but at the next visit the tour shouldn't start automatically, but when you click a button. I am guessing this can be done with "storage", but I don't know how. Can anyone help please? Thanks
问问题
902 次
2 回答
1
我们应该遇到同样的问题,在这里查看我的问题和答案:Bootstrap tour needs to clear cache to work again。
使用 restart() 而不是 start() 或设置“storage: false”可以解决问题。
于 2015-02-12T06:21:33.153 回答
1
“存储”需要是“ window.localStorage ”。此值为默认值,因此您无需添加任何选项。
// Instance the tour
var tour = new Tour();
tour.addSteps([
{
element: "#one",
title: "First",
content: "First Content",
placement: "right"
}, {
element: "#two",
title: "Second",
content: "Second content",
placement: "right"
}
]);
tour.init();
tour.start();
$("#startTour").click(function () {
tour.restart();
})
div#one {
padding:20px;
margin:50px;
width:100px;
height:100px;
background-color:gray;
}
div#two {
padding:20px;
margin:50px;
width:100px;
height:100px;
background-color:aqua;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.10.1/css/bootstrap-tour.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-tour/0.10.1/js/bootstrap-tour.js"></script>
<div id="one">First step</div>
<br>
<div id="two">Second step</div>
<div>
<button id="startTour" class="btn btn-success">Start</button>
</div>
于 2014-12-22T17:57:41.530 回答