jQuery plugin development pattern

I'm currently diving more and more into the jQuery library. First I'm using it on a portlet I'm developing for the Liferay portal server as the project for a university course and secondly I'm planning to use jQuery on some ajax-enabled server controls I'm designing (I'm not yet 100% sure whether to use jQuery or Asp.net Ajax for ajax communication).

All I can say till now is that jQuery is really cool and it dramatically improves your JavaScript programming abilities. Some time ago I found this website which has some nice posts about jQuery. Since I'm a strong promoter of design patterns, I'd like to particularly share this post which highlights a common design pattern for developing jQuery plugins:
I've been developing jQuery plugins for quite a while now, and I've become rather comfortable with a particular style of plugin development for my scripts. This article is meant to share the pattern that I've found especially useful for plugin authoring. It assumes you already have an understanding of plugin development for jQuery; if you're a novice plugin author, please review the jQuery Authoring Guidelines first.
There are a few requirements that I feel this pattern handles nicely:
  1. Claim only a single name in the jQuery namespace
  2. Accept an options argument to control plugin behavior
  3. Provide public access to default plugin settings
  4. Provide public access to secondary functions (as applicable)
  5. Keep private functions private
  6. Support the Metadata Plugin

I'll cover these requirements one by one, and as we work through them we'll build a simple plugin which highlights text....read moreĀ»



Your ad here?