2013-09-15 3 views
4

Я играю с Bootstrap Tour, и я обнаружил, что застрял в навигации по страницам.Bootstrap Tour - Как вернуться с целевой страницы?

В моем туре шаг 4 принимает пользователей от index.cshtml к page.cshtml, который отлично работает, однако окно тура не открывается в page.cshtml, поэтому я не могу перейти с целевой страницы.

В демоверсии тура Bootstrap на bootstraptour.com Я не могу определить javascript, чтобы открыть всплывающее окно тура в page.cshtml или обработать возврат обратно к index.cshtml. Существует только div с классом, называемым контейнером, и ссылками на ссылку в демо-странице Bootstraptour page.html.

Я пробовал разные варианты без радости. Итак, может ли кто-нибудь помочь мне открыть всплывающее окно в page.cshtml и использовать его для перехода к исходному index.cshtml? Благодарю.

Вот что у меня есть:

index.cshtml

@{  
} 
<!DOCTYPE html> 

<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 
     <title></title> 

     <!-- Le Bootstrap Styles --> 
     <link href="../assets/css/bootstrap.css" rel="stylesheet"> 
     <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> 

     <!-- Bootstrap Tour --> 
     <link href="../bootstrap-tour/bootstrap-tour.css" rel="stylesheet"> 

    </head> 

<body> 

</br> 
    </br> 

      <p class="step-handle" id="step-welcome"> step welcome </p></br> 
      <p class="step-handle" id="step-one"> step 1</p></br> 
      <p class="step-handle" id="step-two"> step 2 </p></br> 
      <p class="step-handle" id="step-three"> step 3 </p></br> 
      <p class="step-handle" id="step-four"> step 4</p></br> 
      <p class="step-handle" id="step-five"> step 5 </p></br> <!-- DOES STEP FIVE GO IN page.cshtml? --> 
      <p class="step-handle" id="step-six"> step 6</p></br> 

<hr /> 

<button id="pause-tour">Pause Tour</button> 
<hr /> 
<button id="resume-tour">Resume Tour</button> 


    </body> 
</html> 
     <!-- Le javascript 
    ================================================== --> 
    <!-- Placed at the end of the document so the pages load faster --> 
    <script src="../bootstrap-tour/jquery.js"></script> 
    <script src="../bootstrap-tour/bootstrap-tooltip.js"></script> 
    <script src="../bootstrap-tour/bootstrap-popover.js"></script> 
    <script src="../bootstrap-tour/bootstrap-tour.js"></script> 

<script type="text/javascript"> 

var tour = new Tour({ 
    afterSetState: function(key, value) { 
       console.log(key, value, tour.getState(), tour.getStep()); 
      } 
}); 

tour.addSteps([ 
     { 
     element: "#welcome", 
     title: "WELCOME", 
     content: "Welcome to the bootstrap tour" 
    }, 
    { 
     element: "#step-one", // string (jQuery selector) - html element next to which the step popover should be shown 
     title: "Step One Title", // string - title of the popover 
     content: "Step One Content" // string - content of the popover 
    }, 
    { 
     element: "#step-two", 
     title: "Step Two Title", 
     content: "Step Two Content" 
    }, 
    { 
     element: "#step-three", 
     title: "Step Three Title", 
     content: "Step Three Content" 
    }, 
    { 
     path: "/page.cshtml", 
     element: "#step-four", 
     title: "Step four Title", 
     content: "Step four Content" 
    }, 
    { 
     path: "/", 
     title: "Step five Title", 
     content: "Step five Content" 
    }, 
    { 
     element: "#step-six", 
     title: "Step six Title", 
     content: "Step six Content" 
    } 
]); 

tour.restart(); 

$("#pause-tour").on("click", function() { 

    tour.end(); 

}); 


$("#resume-tour").on("click", function() { 

    tour.start(true); 

}); 
</script> 

page.cshtml

@{ 

} 

<!DOCTYPE html> 

<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 
     <title></title> 


     <!-- Le Bootstrap Styles --> 
     <link href="../assets/css/bootstrap.css" rel="stylesheet"> 
     <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> 

     <!-- Bootstrap Tour --> 
     <link href="../bootstrap-tour/bootstrap-tour.css" rel="stylesheet"> 


    </head> 


    <body> 


     <div class="container"> 
      <h1>This is just a test.</h1> 
      <p>Nothing to see here. Move on!</p> 
     </div> 

    </body> 
</html> 
     <!-- Le javascript 
    ================================================== --> 
    <!-- Placed at the end of the document so the pages load faster --> 
    <script src="../bootstrap-tour/jquery.js"></script> 
    <script src="../bootstrap-tour/bootstrap-tooltip.js"></script> 
    <script src="../bootstrap-tour/bootstrap-popover.js"></script> 
    <script src="../bootstrap-tour/bootstrap-tour.js"></script> 

ответ

2

Я вижу несколько проблем:

  1. Элемента указывается на четвертом этапе (#step-four) не найден в разметке для page.cshtml

  2. Шага пять не имеет element определена, я считаю, один требуется, если вы установите опцию orphan в true

  3. Вы также должны указать весь код тура в page.cshtml, если вы проверили источник демо в page.html, последний ссылочный скрипт index.js содержит экземпляр тура.

Наконец, я не уверен, если это будет делать какие-либо различия, но я думаю, что ваши звонки на tour.restart(); и tour.start(true); должны поменять местами

+0

Hi koala_dev, спасибо за помощь. У моих попыток page.cshtml было # шага-четыре, и определился элемент пятого шага (который, должно быть, упал с вырезания и вставки в этот пост). Поскольку я не мог включить все различные варианты page.cshtml, которые я пробовал, я оставил шаблон page.cshtml, чтобы увидеть, добавит ли кто-нибудь ответный шаг, чтобы показать мне, как вернуться к index.cshtml. Сначала у меня был код на обеих страницах, и js почти работал, перелистывая страницы. Я «пропустил» упоминаемые js в демо, хотя это меня бросило, поэтому «спасибо» за это. Во всяком случае, я добрался туда (см. Выше) Спасибо – DaniB

+0

У меня такая же проблема, как у Danib лицом ,,, если вы мне поможете @koala_dev –

1

После того, как другой взгляд на то, как навигации по страницам в туре я получил назад к тому, где я был вчера: тур меняется с index.cshtml на page.cshtml и обратно, но это происходит в один клик - page.cshtml только начинает мигать. Всплывающее окно шага не открывается в page.cshtml, и мы не остаемся на этой странице.

Итак, я думал, что добавлю еще один шаг на страницу page.cshtml (шаг пять и шаг шесть) и BINGO!

Благодаря kuala_dev для указателя. Рабочий код ниже:

INDEX.CSHTML

@{  
} 
<!DOCTYPE html> 

<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 
     <title></title> 

     <!-- Le Bootstrap Styles --> 
     <link href="../assets/css/bootstrap.css" rel="stylesheet"> 
     <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> 

     <!-- Bootstrap Tour --> 
     <link href="../bootstrap-tour/bootstrap-tour.css" rel="stylesheet"> 

    </head> 

<body> 

</br> 
    </br> 

      <p class="step-handle" id="step-welcome"> step welcome </p></br> 
      <p class="step-handle" id="step-one"> step 1</p></br> 
      <p class="step-handle" id="step-two"> step 2 </p></br> 
      <p class="step-handle" id="step-three"> step 3 </p></br> 
      <p class="step-handle" id="step-four"> step 4</p></br> 

      <p class="step-handle" id="step-seven"> step 7</p></br> 

<hr /> 

<button id="pause-tour">Pause Tour</button> 
<hr /> 
<button id="resume-tour">Resume Tour</button> 


    </body> 
</html> 
     <!-- Le javascript 
    ================================================== --> 
    <!-- Placed at the end of the document so the pages load faster --> 
    <script src="../bootstrap-tour/jquery.js"></script> 
    <script src="../bootstrap-tour/bootstrap-tooltip.js"></script> 
    <script src="../bootstrap-tour/bootstrap-popover.js"></script> 
    <script src="../bootstrap-tour/bootstrap-tour.js"></script> 

<script type="text/javascript"> 

var tour = new Tour({ 
    afterSetState: function(key, value) { 
       console.log(key, value, tour.getState(), tour.getStep()); 
      } 
}); 

tour.addSteps([ 
     { 
     element: "#welcome", 
     title: "WELCOME", 
     content: "Welcome to the bootstrap tour" 
    }, 
    { 
     element: "#step-one", 
     title: "Step One Title", 
     content: "Step One Content" 
    }, 
    { 
     element: "#step-two", 
     title: "Step Two Title", 
     content: "Step Two Content" 
    }, 
    { 
     element: "#step-three", 
     title: "Step three Title", 
     content: "Step three Content" 
    }, 
    { 
     path: "/page.cshtml", 
     element: "#step-four", 
     title: "Step four Title", 
     content: "Step four Content" 
    }, 
     { 
     element: "#step-five", 
     title: "Step five Title", 
     content: "Step five Content" 
    }, 
    { 
     path: "/index.cshtml", 
     element: "#step-six", 
     title: "Step six Title", 
     content: "Step six Content" 
    }, 
    { 
     element: "#step-seven", 
     title: "Step seven Title", 
     content: "Step seven Content" 
    } 
]); 

tour.restart(); 

$("#pause-tour").on("click", function() { 

    tour.end(); 

}); 


$("#resume-tour").on("click", function() { 

    tour.start(true); 

}); 
</script> 

PAGE.CSHTML

@{ 

} 

<!DOCTYPE html> 

<html lang="en"> 
    <head> 
     <meta charset="utf-8" /> 
     <title></title> 


     <!-- Le Bootstrap Styles --> 
     <link href="../assets/css/bootstrap.css" rel="stylesheet"> 
     <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> 

     <!-- Bootstrap Tour --> 
     <link href="../bootstrap-tour/bootstrap-tour.css" rel="stylesheet"> 


    </head> 


    <body> 


      <hr> 

<h2 class="step-handle" id="step-five" style="float: left">We're Big Show Offs</h2> 

      <hr> 

<h2 class="step-handle" id="step-six" style="float: left">We're Big Show Offs</h2> 

    </body> 
</html> 
     <!-- Le javascript 
    ================================================== --> 
    <!-- Placed at the end of the document so the pages load faster --> 
    <script src="../bootstrap-tour/jquery.js"></script> 
    <script src="../bootstrap-tour/bootstrap-tooltip.js"></script> 
    <script src="../bootstrap-tour/bootstrap-popover.js"></script> 
    <script src="../bootstrap-tour/bootstrap-tour.js"></script> 

<script type="text/javascript"> 

var tour = new Tour({ 
    afterSetState: function(key, value) { 
       console.log(key, value, tour.getState(), tour.getStep()); 
      } 
}); 

tour.addSteps([ 
     { 
     element: "#welcome", 
     title: "WELCOME", 
     content: "Welcome to the bootstrap tour" 
    }, 
    { 
     element: "#step-one", 
     title: "Step One Title", 
     content: "Step One Content" 
    }, 
    { 
     element: "#step-two", 
     title: "Step Two Title", 
     content: "Step Two Content" 
    }, 
    { 
     element: "#step-three", 
     title: "Step three Title", 
     content: "Step three Content" 
    }, 
    { 
     path: "/page.cshtml", 
     element: "#step-four", 
     title: "Step four Title", 
     content: "Step four Content" 
    }, 
     { 
     element: "#step-five", 
     title: "Step five Title", 
     content: "Step five Content" 
    }, 
    { 
     path: "/index.cshtml", 
     element: "#step-six", 
     title: "Step six Title", 
     content: "Step six Content" 
    }, 
    { 
     element: "#step-seven", 
     title: "Step seven Title", 
     content: "Step seven Content" 
    } 
]); 

tour.restart(); 

$("#pause-tour").on("click", function() { 

    tour.end(); 

}); 


$("#resume-tour").on("click", function() { 

    tour.start(true); 

}); 
</script> 
+0

Вам не нужно добавлять дополнительный шаг, возможно, он работал неправильно, вы вызываете 'tour.restart()' вместо 'tour.start()' –

+0

Эй, еще раз спасибо koala_dev, вы были правы, я должен был использовать tour.start() - тур работает всего на один шаг. Я очень ценю вашу поддержку. – DaniB

+0

Gald, чтобы помочь, вы не скажете, что ответ, который я опубликовал, был правильным? Я заметил, что, возможно, что-то случилось с вызовом 'restart()' –

Смежные вопросы