代码之家  ›  专栏  ›  技术社区  ›  cusspvz

jQuery:prettypto API不工作

  •  18
  • cusspvz  · 技术社区  · 15 年前

    我正在尝试使用prettipotoAPI,但是firebug说$.prettipoto.open()不是一个函数,不能工作。。。

    代码: http://jsbin.com/ihuje3/3/edit

    $(document).ready(function(){
         $.prettyPhoto.open('http://www.microdual.com/assets/images/newsletters/doublehosting.jpg','Test','Test desc');
    });
    ​
    
    1 回复  |  直到 13 年前
        1
  •  41
  •   Nick Craver    15 年前

    必须先设置prettypto(不幸的是,由于插件是如何编写的),如下所示:

    $(document).ready(function(){
      $.fn.prettyPhoto(); //usually $("a[rel^='prettyPhoto']").prettyPhoto();
      $.prettyPhoto.open('http://www.microdual.com/assets/images/newsletters/doublehosting.jpg','Test','Test desc');
    });
    

    You can see in the source 功能类似于 $.prettyPhoto.open() 由运行`$定义。

    另一个问题是这个插件似乎与jQuery 1.4.4中引入的调用方上下文有问题,它在1.4.3中运行良好( you can test it here ). This has been reported on the forums ,希望作者能尽快解决。 ​

    推荐文章