I thought about this approach as well but then you gotta think that
this is a plugin that others will use and possibly other plugins might
depend on it as well. Then if the defaults changed, the plugin that
depends on it could be confused and break. It is easy enough for a
devloper to setup their own set of defaults that would not cause an
issue like this.
var myHoverDefaults = { interval: 250 };
Now just pass that in and your set and don't potentially break any
other plugins.
As an example ... I'm updating my bgiframe plugin to accept an options
hash. If I allowed a developer/plugin to change the defaults then all
the plugins that depend on the defaults would then break.
Hopefully that all made sense ... I'm writing it in a bit of a rush.
--
Brandon Aaron
On 3/13/07, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> Brandon Aaron schrieb:
> > Very nice. I believe this will be getting a fair amount of usage!
> >
> >
> >> - ability to override default settings (sensitivity, polling interval, etc)
> >>
> > This would be great and probably should be done by passing an options
> > hash as the third argument. Usually options as passed as the first
> > argument in plugins but it makes sense to be the third in this case.
> >
> > I would imagine it looking something like this:
> >
> > jQuery.fn.hoverIntent = function(f,g,o) {
> > o = jQuery.extend({ sensitivity: 4, interval: 100 }, o || {});
> > ...
> > };
> >
> How about this then...
>
> jQuery.fn.hoverIntent = function (on,off,options) {
> var settings = jQuery.extend({}, jQuery.hoverIntent.defaults, options);
> ...
> };
> jQuery.hoverIntent = {};
> jQuery.extend({
> defaults: { sensitivity: 4, interval: 100 },
> setDefaults: function(settings) {
> jQuery.extend(jQuery.hoverIntent.defaults, settings);
> }
> });
>
> I like that approach. Gives your users the chance to set defaults
> directly or more then one using setDefaults:
>
> jQuery.hoverIntent.setDefaults({
> interval: 250
> });
>
> --
> Jörn Zaefferer
>
> http://bassistance.de
>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/