我实现了巨大的 [galleriffic][0] - jQuery 插件,并希望在每张图片上设置一个类似 facebook 的按钮。现在我在 onSlideChange() 函数中尝试了它,如下所示:
$(".fb-like").attr("data-href","http://ulc.local/galerie/25#"+nextIndex);
但没有成功。一旦我单击一个喜欢按钮,其他图片上的所有其他按钮也会启用。
任何帮助深表感谢。
编辑:这是更多代码:
<div id="gallery" class="content-image">
<div class="border-left"></div>
<div class="slideshow-container">
<div id="loading" class="loader"></div>
<div id="slideshow" class="slideshow">
<div id="slide-container">
<div id="slider">
<div id="title"></div>
<div id="share">
<div class="fb-like" data-send="false" data-layout="button_count" data-width="150" data-show-faces="true"></div>
<div id="spacer"></div>
<a href="https://twitter.com/share" class="twitter-share-button" data-lang="en" data-count="none"></a>
</div>
</div>
</div>
</div>
</div>
<div class="border-right"></div>
</div>
<div style="clear:both"></div>
类“fb-like”的 div 应该显示按钮。现在我尝试在 onSlidechange() 中用这个 div 替换这个 div:
onSlideChange:function(prevIndex, nextIndex) {
// 'this' refers to the gallery, which is an extension of $('#thumbs')
this.find('ul.thumbs').children()
.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
.eq(nextIndex).fadeTo('fast', 1.0);
newUrl = "http://ulc.local/galerie/25/";
$(".fb-like").replaceWith("<div class='fb-like' data-href='http://ulc.local/galerie/25#' "+nextIndex+" data-send='false' data-layout='button_count' data-width='150' data-show-faces='true'></div>");
}
我想制作几个类似按钮,一旦用户单击下一张图像,我就会更改 data-href 属性。不幸的是,没有显示任何按钮。