I want to make my bootstrap tour start when a button is clicked. But for some strange reason it doesn't work. I've putted the js files in the head and the rest in a widget (so in the body). It's all working fine if autostart is enabled (start if the page is loaded). But I want to let it work if a certain button is clicked.
The following code does work:
<script src="https://code.jquery.com/jquery-1.7.1.js"></script>
<script src="http://localhost/bodybuildrecepten/wp-content/plugins/bootstrap-tour/bootstrap-tour-standalone.min.js"></script>
<script>
// Instance the tour
var tour = new Tour({
debug: true,
storage: false,
steps: [
{
element: "#menu-item-2991",
title: "Settings",
content: "Content of settings",
placement: "right"
},
{
element: "#test2",
title: "Title of my step",
content: "Content of my step",
placement: "right",
onShow: function() {
return $("#appSettings").addClass("open");
},
onHide: function() {
$("#appSettings").removeClass("open");
}
}
]});
tour.init();
tour.start();
</script>
But I want to execute the tour when a button is clicked So I've made a button:
<button id="starttour">Start the tour!</button>
And I've changed the code to (and tried other options, but no success):
<script src="https://code.jquery.com/jquery-1.7.1.js"></script>
<script src="http://localhost/bodybuildrecepten/wp-content/plugins/bootstrap-tour/bootstrap-tour-standalone.min.js"></script>
<script>
// Instance the tour
var tour = new Tour({
debug: true,
storage: false,
steps: [
{
element: "#menu-item-2991",
title: "Settings",
content: "Content of settings",
placement: "right"
},
{
element: "#test2",
title: "Title of my step",
content: "Content of my step",
placement: "right",
onShow: function() {
return $("#appSettings").addClass("open");
},
onHide: function() {
$("#appSettings").removeClass("open");
}
}
]});
tour.init();
$("#starttour").click(function(){
tour.start();
});
</script>
I hope anybody can see what's going wrong. Any help is appreciated!
Edit: tried jQuery instead of a dollar sign. No succes.
These are the errors my console shows: http://oi60.tinypic.com/24y5lz7.jpg