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).
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:
- Claim only a single name in the jQuery namespace
- Accept an options argument to control plugin behavior
- Provide public access to default plugin settings
- Provide public access to secondary functions (as applicable)
- Keep private functions private
- 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»