Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery: PrettyPhoto API isn't working

i'm trying to use prettyPhoto API, but firebug says that $.prettyPhoto.open() isn't a function and don't work...

CODE: http://jsbin.com/ihuje3/3/edit

$(document).ready(function(){
     $.prettyPhoto.open('http://www.microdual.com/assets/images/newsletters/doublehosting.jpg','Test','Test desc');
});
​
like image 338
cusspvz Avatar asked Nov 24 '10 11:11

cusspvz


1 Answers

You have to setup prettyPhoto first (because of how the plugin is written, unfortunately), like this:

$(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 that functions like $.prettyPhoto.open() are defined by running `$.

The other issue is the plugin seems to have an issue with caller context introduced in jQuery 1.4.4, it works fine with 1.4.3 (you can test it here). This has been reported on the forums, hopefully the author will address it soon. ​

like image 88
Nick Craver Avatar answered Oct 01 '22 23:10

Nick Craver