简体   繁体   English

Zurb的基金会'Joyride':如何开始/编程

[英]Zurb's Foundation 'Joyride': how to start/programmatically

I'm using Foundation 4 Joyride plugin but I need it to start (and re-start) once a user clicks a certain button on my UI, but I'm not being able to do so. 我正在使用Foundation 4 Joyride插件,但是一旦用户点击我的UI上的某个按钮,我就需要它来启动(并重新启动),但我无法这样做。 By following the code presented on Zurb's site I'm only able to run it when the site first runs. 通过遵循Zurb网站上提供的代码,我只能在网站首次运行时运行它。

The docs for Joyride are here: Joyride的文档在这里:

http://foundation.zurb.com/docs/components/joyride.html http://foundation.zurb.com/docs/components/joyride.html

and my init code is here 我的初始代码在这里

  $(document).foundation().foundation('joyride', 'start', {template : { // HTML segments for tip layout
    link    : '<a href="#close" class="joyride-close-tip " style="background: url(../img/bp_sprite.png) no-repeat 0px -940px; margin-top: -4px; ">&nbsp;&nbsp;</a>',
    timer   : '<div class="joyride-timer-indicator-wrap"><span class="joyride-timer-indicator"></span></div>',
    tip     : '<div class="joyride-tip-guide" style="background: white; color: black; margin-top: -27px; margin-left: 2px; border-top: 1px dashed #c1c1c1; width: 100%; max-width: 457px;"></div>',
    wrapper : '<div class="joyride-content-wrapper" style="background-color: white; color: black; padding: 4px;  "></div>',
    button  : '<a href="#" class="small button joyride-next-tip" style="display: none;"></a>'
  }});

I bumped up against this as well. 我也反对这一点。 What you need to do is wrap the tag inside of a with an ID, and then call the joyride start command against that. 您需要做的是将标记包装在带有ID的标记内,然后针对该标记调用joyride start命令。

For example, the markup might look like this: 例如,标记可能如下所示:

<div id="joyrideDiv">
<ol class="joyride-list" data-joyride>
  <li data-id="joyridedElement"><p>Here's the explanation</p></li>
</ol>
</div>

And then you can start just that joyride by calling foundation (this is key) against that div only. 然后你可以通过调用基础(这是关键)来启动这个兜风只对那个div。 The call would look like this: 电话会是这样的:

$("#joyrideDiv").foundation('joyride', 'start');

Note that you're passing the ID of the wrapper div, not the ID of the element. 请注意,您传递的是包装器div的ID,而不是元素的ID。 I had to poke around in the source to figure that out. 我不得不在消息来源中找到答案。

You can also just launch joyride if you set the autostart property to true. 如果将autostart属性设置为true,也可以启动joyride。 To make sure you clear all previous joyride tours, if you switch between a few tours, you can clear the previous tours by calling the destroy function. 为了确保清除所有以前的兜风之旅,如果您在几个巡视之间切换,您可以通过调用destroy函数清除之前的巡演。

jQuery(window).joyride("destroy");
jQuery("#ot-introduction").joyride({autoStart: true});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM