views:

624

answers:

4

Beyond the official documentation, are there any recommended resources for learning to build jQuery plugins. I'm particularly interested in building plugins for the UI libary.

I've been looking at the source for some of the official ones, but I've found they all look quite different from each other. Many are not well commented and it is difficult to tell what blocks of code are part of the essential structure and what is specific to a particular plugin.

If there aren't yet any good resources for this, can anyone clue me in on what basic structure I should be starting with when writing a plugin from scratch?

+1  A: 

Have you tried the Manning Publications book on jQuery, jQuery In Action? The table of contents indicates there is good material on writing your own plugins.

hughdbrown
+1  A: 

Chapter 7 of JQuery in Action is "Extending JQuery with custom Plugins" and should provide you with the information you need.

Don
+1  A: 

Try this one. This tutorial will take you step by step through creating your very own plugin.

Chatu
+2  A: 

Tutorial at "Learning jQuery"

Learning jQuery is a very helpful site, and has a great tutorial on plugin authoring.

One principle I really liked was: create default settings that users can override.

So maybe you can say $(this).highlight() and it will highlight blue by default. Or you can say $(this).highlight("green") and it will highlight green.

But you should also make it possible to say:

   $(this).highlight({
    foreground: 'red'
    });

...and it will highlight red from then on by default.

Nathan Long