1

以下是我的参考代码:

我正在为我的应用程序使用 Bootstrap 导览。

要求 :

  • 当我单击下一步时,我处于第一步,然后它正在检查“#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');          
            }           
        }
    ]);
4

1 回答 1

1

I've fiddled around with it and it seems that you should put the goTo() logic on the step you want to skip:

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();
于 2014-05-10T13:03:29.573 回答