Exos
Exos

Reputation: 3988

jQuery plugin access

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??

Upvotes: 4

Views: 239

Answers (1)

Alnitak
Alnitak

Reputation: 339796

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

Upvotes: 5

Related Questions