2

谁能解释如何将 PrettyPhoto 与 livequery 一起使用?

  $(document).ready(function()
  {
    $(".gallery a[rel^='prettyPhoto']").livequery(
    function()
    {
      $(this).prettyPhoto({theme:'facebook'});
    });
  });

代码是正确的,但我认为 livequery 不支持 PrettyPhoto。有人可以确认吗?

4

3 回答 3

6

你在谈论jQuery吗?如果是这样,我已经得到了这个工作:

$("a[rel=prettyPhoto]").live("click",function() {
    $.prettyPhoto.open($(this).attr("href"),"","");
    return false;
});

如果你想加入一些主题或你可以做的事情:

$.fn.prettyPhoto({'theme': 'light_rounded'});
$("a[rel=prettyPhoto]").live("click",function() {
    $.prettyPhoto.open($(this).attr("href"),"","");
    return false;
});
于 2011-02-04T08:10:11.847 回答
1
$.fn.prettyPhoto({
    animation_speed: 'fast', /* fast/slow/normal */
    slideshow: 5000, /* false OR interval time in ms */
    theme: 'facebook' /* light_rounded / dark_rounded / light_square / dark_square / facebook /pp_default*/
});

$.prettyPhoto.open('xzs.html?iframe=true&width=100%&height=100%','Title','DESC');

User
<a style="color: #F99;text-decoration:inherit;" href="javascript:;" rel="prettyPhoto[iframes]" name="xzs.html?iframe=true&width=100%&height=100%" title="test">test</a>

$("a[rel^='prettyPhoto']").livequery(function(){
    var url = $(this).attr(name);
    $.prettyPhoto.open(url,'Title','DESC');
});
于 2011-12-13T05:39:46.060 回答
0

发生的情况是 prrettyPhoto 为每张照片实例化一个画廊,而不是使用rel属性上的正则表达式来构建集合。您需要做的是,每当您在 DOM 中获得新的初始化时,都重新运行初始化。 a[rel^='prettyPhoto']这是由于 prettyPhoto 使用全局变量设置的方式matchedObjects

于 2011-10-11T16:07:23.217 回答