开发者

jQuery plugin access

开发者 https://www.devze.com 2023-03-06 08:28 出处:网络
I\'m doing a youtube player in jQuery, and I make this as a jQuery plugin, ex: $.fn.extend({ uplayList: {},

I'm doing a youtube player in jQuery, and I make this as a jQuery plugin, ex:

 $.fn.extend({

        uplayList: {},

        CreateUplayList: function (options) {
            this.each(function  () {
                $(this).uplayList = new $.playList(this, options);
           开发者_开发问答 });
        }
    });

But, if I do:

$('#playlist').CreateUplayList({....});

And I want access at the instance:

$('#playlist').uplayList.play();

This not work, that make sense, because $('#playlist') is a selector. I see in others plugins something like that:

$('#playlist').pluginname('play');

How can I apply this??


See the "Adding Methods to a Widget" section of the "Stateful Plugins" section of the jQuery Plugin Authoring Guide.

0

精彩评论

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