using entwine to create plugins with options

8 views
Skip to first unread message

Venkat

unread,
Jan 20, 2010, 1:01:39 PM1/20/10
to jQuery Entwine
I have been using your advice at
http://wiki.github.com/hafriedlander/jquery.entwine/using-entwine-to-create-plugins
to create plugins.

What would be the best way to pass the configuration object from the
jquery plugin function call to the entwined object?

Thanks!

hamish

unread,
Feb 28, 2010, 4:54:15 PM2/28/10
to jQuery Entwine

Whoops. Missed this.

On Jan 21, 7:01 am, Venkat <vendi...@gmail.com> wrote:
> I have been using your advice athttp://wiki.github.com/hafriedlander/jquery.entwine/using-entwine-to-...


> to create plugins.
>
> What would be the best way to pass the configuration object from the
> jquery plugin function call to the entwined object?
>
> Thanks!

Easiest is to use Entwine's properties system:

$('.myPlugin').entwine({
Color: 'black',
TabSelector: '> div.tabs'
});

$.fn.myPlugin = function(options) {
$(this).addClass('myPlugin').entwineData(options || {});
});

There are extensions to this pattern, mostly involving overriding the
property getters, that let you also get options from the element's
attributes, or have a 'default' option set on a parent element.

Hamish

Reply all
Reply to author
Forward
0 new messages