开发者

In the jQuery Galleria plugin, pressing the right key moves to the next image. How can I access this method from the page where I use the plugin?

I'm very new to javascript & jQuery, and can't work out how to do this. The source code can be 开发者_Go百科found here. Thanks for reading.


The API isn't very well documented here, but when you run .galleria(), it returns the gallery object, so you can hang on to a reference to it, like this:

var gallery = $('#galleria').galleria();

Then you can use it later to move like you want:

gallery.next(); //move next
gallery.prev(); //move back

Here you're just accessing the next and prev functions defined on the gallery object returned.


I'm re-answering this since the plugin just had a new revision where the accepted answer wont work anymore.

The best way is to use the extend method to attach events to external elements. See the demo available here: http://galleria.aino.se/media/galleria/demos/classic-03.html

You can also fetch the Galleria instance anywhere, like Nick wrote, using:

var gallery = Galleria.get(0); // fetches the first instance

gallery.next();
gallery.prev();

The API has been updated here: http://github.com/aino/galleria/blob/master/docs/

Have a look at public-methods, events and static-methods.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜