2014-05-10 26 views
1

以下是我参考代码:tour.goTo(我)不工作

我使用的引导游览我的应用程序。

要求:

  • 我在第一步当我点击下一步,然后它被检查“#ID2”的价值。 如果id2的值不是空白,那么它应该跳过这一步并直接转到第3步。

对此我试图tour.goTo(3)。 但这不起作用。 有什么帮助吗?

tour.addSteps([ 
     { 
      element:" #id1", 
      title: "1", 
      content: "1st Content.", 
      placement: "top", 
      onShow: function() { 
       console.log('This is Onshow Function'); 
      }, 
      onNext: function() {  
       client_text = $('#id2').text(); 
       if(client_text != ''){ 
        console.log('----------client code present----------'); 
        tour.goTo(3) 
        //tour.next(); 
        //tour.hideStep(2) 
        return false 
       } 
       else{ 
        console.log('-------client code not present--------'); 
       } 
      }, 
      onHidden:function() {  
       tour.hideStep(2) 
       } 
     }, 
     { 
      element:" #id2", 
      title: "2", 
      content: "2nd Content", 
      placement: "top", 
      onShow: function() { 
       console.log('second step');   
      } 
     }, 
     { 
      element:" #id3", 
      title: "3", 
      content: "3rd Content", 
      placement: "top",   
      onShow: function() { 
       console.log('third step');   
      }   
     } 
    ]); 
+0

** goTo(i)**接受基于0的索引_i_。也许你应该尝试** goTo(2)**而不是? – AVK

+0

AVK:好的工作。但第2步仍然可见。 – eegloonew

+0

我试过了隐藏和隐藏,但仍然可以看到步骤2 – eegloonew

回答

1

我拨弄与它周围,似乎你应该把GOTO()逻辑上步要跳过:

HTML

<div id="id1">One</div> 
<div id="id2">Two</div> 
<div id="id3">Three</div> 

JS

var tour = new Tour(); 

tour.addSteps([ 
     { 
      element:" #id1", 
      title: "1", 
      content: "1st Content.", 
      placement: "top", 
      onShow: function() { 
       console.log('This is Onshow Function'); 
      }, 
     }, 
     { 
      element:" #id2", 
      title: "2", 
      content: "2nd Content", 
      placement: "top", 
      onShow: function() { 
       console.log('second step');   
      }, 
      onShown: function() {  
       client_text = $('#id2').text(); 
       if(client_text != ''){ 
        console.log('----------client code present----------'); 
        tour.goTo(2)  
       } 
       else{ 
        console.log('-------client code not present--------'); 
       } 
      }, 
     }, 
     { 
      element:" #id3", 
      title: "3", 
      content: "3rd Content", 
      placement: "top",   
      onShow: function() { 
       console.log('third step');   
      }   
     } 
    ]); 

tour.init(); 

tour.restart(); 
+0

这对于进入下一步很好,但我也想移动上一步。所以试图prev,但它不工作(问题链接是:https://stackoverflow.com/questions/23798461/tour-prev-or-onprev-if-i-am-skipping-step-using-onshown-for- move-next) – eegloonew

+0

如何使用goTo()函数跳过步骤 – Sankar