在 bxcarousel 中的图像上重新绑定 jQuery qtip 工具提示

发布于 2024-08-31 12:28:16 字数 564 浏览 6 评论 0原文

我正在使用 bxcarousel 来显示一堆图像。每个图像都有一个工具提示,我使用 qtip 显示它。

这对于第一轮效果很好,但是当图像第二次出现时,工具提示不再显示(因为 bxcarousel 删除了滑出的元素并将其放回末尾)

可以在此处找到轮播的示例: http://www.kipdola.be/carousel/carousel.html

这是用于绑定事件的代码(也许它需要某个地方的“实时”函数?)

// Create the tooltips only on document load
$(document).ready(function() 
{
   // Use the each() method to gain access to each elements attributes
   $('#shopcarousel a[rel]').each(function()
   {
      $(this).qtip(

I'm using bxcarousel to show a bunch of images. Each image has a tooltip, which I display using qtip.

This works fine for the first round, but when the images come round a second time the tooltips don't show anymore (because bxcarousel removes an element that slides out and puts it back at the end)

An example of the carousel can be found here:
http://www.kipdola.be/carousel/carousel.html

This is the code used to bind the events (maybe it needs a "live" function somewhere?)

// Create the tooltips only on document load
$(document).ready(function() 
{
   // Use the each() method to gain access to each elements attributes
   $('#shopcarousel a[rel]').each(function()
   {
      $(this).qtip(

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

过期情话 2024-09-07 12:28:16

我最终出于类似的目的修改了 bxCarousel。以下是我的步骤:

1.) 将另一个属性(animation_cb 或回调)添加到默认对象。该属性应用于传递一个回调函数,在每个动画周期的尾部执行:

var defaults = {
    ...
    controls: true,
    animation_cb: null
};

2.)向slide_next和slide_prev函数添加对该选项的检查:

function slide_next(){
    ...
    get_a();
    if (typeof options.animation_cb === "function") options.animation_cb();
    is_working = false;
    ...
}

并且:

function slide_prev(){
    ...
    get_p()
    if (typeof options.animation_cb === "function") options.animation_cb();
    is_working = false;
    ...
}

3.)最后,在您的插件初始化中调用时,传递一个要执行的回调函数。例如:

function doBar () {
    // whatever you need to happen after the slides have moved
    // like rebinding events, or what have you
}

$('ul.foo').bxCarousel({
    ...
    animation_cb: doBar
});

I ended up modifying bxCarousel for a similar purpose. Here are my steps:

1.) Add another property (animation_cb, or callback) to the defaults object. This property should be used to pass a callback function, to be executed at the tail end of each animation cycle:

var defaults = {
    ...
    controls: true,
    animation_cb: null
};

2.) Add a check for the option to the slide_next and slide_prev functions:

function slide_next(){
    ...
    get_a();
    if (typeof options.animation_cb === "function") options.animation_cb();
    is_working = false;
    ...
}

And:

function slide_prev(){
    ...
    get_p()
    if (typeof options.animation_cb === "function") options.animation_cb();
    is_working = false;
    ...
}

3.) Finally, in your plugin initialization call, pass a callback function to be executed. For example:

function doBar () {
    // whatever you need to happen after the slides have moved
    // like rebinding events, or what have you
}

$('ul.foo').bxCarousel({
    ...
    animation_cb: doBar
});
念三年u 2024-09-07 12:28:16

qTip 不能很好地处理 .live() 事件...我尝试了这样的方法:

$('#shopcarousel a[rel]').live('mouseover', function(){... })

但效果不佳,因为有时您必须离开该元素然后再返回要显示的工具提示。

更好的选择是使用与 .live() 事件绑定的工具提示。我找不到很多,而且它们仍然相对基本:

  1. 简单工具提示(制作您自己的教程)
  2. Tipsy (我不确定这是否设置为使用 Ajax 加载内容)
  3. monnaTip (来自此SO答案

qTip doesn't work well with .live() events... I tried something like this:

$('#shopcarousel a[rel]').live('mouseover', function(){... })

but it didn't work well because at times you would have to move off of the element then back for the tooltip to show.

A better alternative would be to use a tooltip that binds with .live() events. I couldn't find many, and they are still relatively basic:

  1. Simple Tooltip (tutorial to make your own)
  2. Tipsy (I'm not sure if this is set up to load content using Ajax)
  3. monnaTip (from this SO answer)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文