News for hackers. Stuff that matters.
Re:Superior jQuery plugin template by deadbeef84 on Monday March 19, 2012 @01:18PM (#3724952)
Here's my thoughts:

1. Ability to modify default settings It is sometimes nice to set the global defaults.

2. Ability to expose methods. A nice way of calling the someFunc() would be nice. I guess you can do it like this: $(...).data('_wTooltip').someFunc(); but using the data() seems a bit hacky.

3. Use settings from html5 data-attribute, ie data-tooltip='{"foo":"baar"}'. Not really necessary for the example plugin, but I think it could be for others. I hate it when I need initialize every instance separately just to specify it's options, when they could be specified in the markup.

4. Missing var before $settings. Just a typo I guess?

5. I think the name generate() is a bit misleading, init() or initialize() makes more sense to me.

Re:Superior jQuery plugin template by rduchnik on Monday March 19, 2012 @01:35PM (#3725065)
I like your points for 1 and 2, will add those in the next iteration, constantly trying to improve this thing.

I didn't use init() because sometimes I may use init to do something else that doesn't deal with generating the plugin code, so I ended up going with generate(), maybe create() would be a better word.

Re:Superior jQuery plugin template by robin_reala on Monday March 19, 2012 @01:27PM (#3725008)
Not sure you should be (ab)using data- attributes like that. They’re already a key/value pair so you markup your data as <div data-tooltip-foo="baa" data-tooltip-qux="quux">
Re:Superior jQuery plugin template by deadbeef84 on Monday March 19, 2012 @01:38PM (#3725086)
If you have many options, they are easier to retrieve, just call .data('tooltip') and jQuery will do the parsing of the object. Using separate attributes you would have to call .data() for every attribute. Anyway, I guess any of the two methods would be fine! :-)
Re:Superior jQuery plugin template by deadbeef84 on Monday March 19, 2012 @01:22PM (#3724978)
6. Prevention of double instantiation.
Re:Superior jQuery plugin template by paulirish on Monday March 19, 2012 @04:33PM (#3726051)
A recipe like this (also a tooltip), but approved by the jQuery team and with much more explanation is available at http://docs.jquery.com/Plugins/Authoring
Re:Superior jQuery plugin template by rduchnik on Monday March 19, 2012 @04:52PM (#3726151)
ya, I don't really like their method approach, they don't use prototyping.
Re:Superior jQuery plugin template by Rust on Wednesday March 21, 2012 @03:41PM (#3736202)
Just wanted to let you know I used your boilerplate for my first jQuery plugin recently - https://github.com/indyarmy/jQuery.awesomeCloud.plugin/

Thanks a lot, it saved me a pile o'trouble :)

Re:Superior jQuery plugin template by AndrewHampton on Monday March 19, 2012 @12:39PM (#3724681)
The first line of $.fn.wTooltip is

  if(typeof option === 'object')
Does anyone know where option is declared and where its value is set?
Re:Superior jQuery plugin template by lhorie on Monday March 19, 2012 @12:48PM (#3724744)
It's meant to be the first argument passed to the plugin, e.g.

  $("#bla").wTooltip({foo: "bar"})
Re:Superior jQuery plugin template by rduchnik on Monday March 19, 2012 @12:46PM (#3724737)
My bad, fixed it, was supposed to be here:

    $.fn.wTooltip = function(option, settings)
Re:Superior jQuery plugin template by ftyhgjn on Monday March 19, 2012 @12:58PM (#3724821)
'Untested' and 'superior' are not happy bedfellows!
Re:Superior jQuery plugin template by rduchnik on Monday March 19, 2012 @01:25PM (#3724995)
lol, just a typo ;)
Re:Superior jQuery plugin template by axiak on Monday March 19, 2012 @03:34PM (#3725747)
What happens if I type:

    $("blah").wTooltip(new String("color"));
In my recent jquery plugin I considered doing a typeof check myself but decided against it since it was too brittle. I instead checked to see if the options was === what I expected it to be first.
Re:Superior jQuery plugin template by rduchnik on Monday March 19, 2012 @04:28PM (#3726018)
Well, I think this is getting a little nit picky. I would rather have a smaller footprint for my plugin then putting a bunch of checks like this in. I don't think I've ever passed in a string that way, that would seem to me like a very rare condition.
Re:Superior jQuery plugin template by emehrkay on Monday March 19, 2012 @03:11PM (#3725629)
Crockford must be rolling over in his bed right now