我目前正在我的网站上进行巡视,但它似乎并没有真正跟踪用户是否点击了结束巡视。这意味着如果他们点击一次,就会结束巡视,但是当他们重新访问该页面时,巡视将自动重新开始,就像他们第一次登陆该页面一样。
var tour = new Tour({
backdrop:true,
onEnd:function(t){
var last = t._options.steps.length;
if(t._current==last-1){
$.post( "home/tourCompleted", function( data ) {});
//$('#tourTracking').attr("step",0);
//$("#tourTracking").addClass("hidden");
}else{
if(t._current==0){
$.post( "home/setCurrentStepTour/0", function( data ) {});
//$('#tourTracking').attr("step",0);
}else{
$.post( "home/setCurrentStepTour/"+t._current, function( data ) {});
//$('#tourTracking').attr("step",t._current);
}
}
if($.browser.device){
$("#dropdownToolbar").removeClass("open4tour open");
}
$("html,body").css('overflow', 'auto');
document.body.removeEventListener('touchstart',null);
},
onShown: function(tour) {
var stepElement = getTourElement(tour);
$(stepElement).after($('.tour-step-background'));
$(stepElement).after($('.tour-backdrop'));
}
});
function getTourElement(tour){
return tour._options.steps[tour._current].element
}
var bookcount = <?php echo count($lstscbook)?>;
if (bookcount == 0){
$('.tour-tour-0').addClass('noBookTour');
tour.addSteps([
{...}
]);
}else{ ... }
<?if(isset($redir4tour) && $redir4tour==TRUE){?>
var redir4tour=true;
<?}else{?>
var redir4tour=false;
<?}?>
if(redir4tour)window.history.pushState({},"", "<?=base_url()?>");
if(($('#tourTracking').attr("step")==0 && !(<?php echo (isset($tour['completed']) ? $tour['completed'] : "false" )?>)) || redir4tour){
document.body.addEventListener('touchstart', function(e){ return true; });
$("html,body").css('overflow', 'hidden');
window.scrollTo(0, 0);
tour.init();
tour.restart(); //using restart -> https://github.com/sorich87/bootstrap-tour/issues/140
}
$("a#tourTracking").click(function(e){
document.body.addEventListener('touchstart', function(e){ return true; });
$("html,body").css('overflow', 'hidden');
window.scrollTo(0, 0);
var step = $('#tourTracking').attr("step");
if($.browser.device && (step==2 || step==14 || step==19 || step==20 || step==21)){//steps in toolbar responsive. have to open toolbar before set step!
$("#dropdownToolbar").addClass("open4tour");
$("#responsiveToolbar").click();
}
window.localStorage.clear();
tour.setCurrentStep(step);
tour.init();
tour.restart(); //using restart -> https://github.com/sorich87/bootstrap-tour/issues/140
});
答案 0 :(得分:1)
我相信这默认使用window.localStorage来实现持久性。你最后用window.localStorage.clear();
清除了吗?
答案 1 :(得分:0)
您可以设置选项:storage: false
以禁用此行为
答案 2 :(得分:0)
我必须在初始化“ var tour = new Tour({”
name: 'tourNew' + Date.now().toString(),
尝试一下,看看它是否也适合您。