background preloader

Jquery-plugins

Facebook Twitter

Maintaining state with jquery plugins. Script Junkie | jWorldmaps: The Anatomy of a jQuery Mapping Plugin. Ever want to know how to write a jQuery plugin? For some of you, the answer may be yes, because learning anything new and cool is what drives you. For others, the answer may well be no, because learning in the abstract isn’t as important as solving the particular problem you’re facing today.

In this article, I’m aiming to satisfy both groups by showing you how I solved a particular problem with my website code by creating a jQuery plugin of my own. Background One common desire for website creators/owners is a tool or tools that will help them measure the reach of their sites. What’s the Problem? Implementing Worldmaps isn’t terribly difficult, nor is showing the map of visitor locations.

Well, in my case, I wasn’t satisfied to just use the standard 160 pixel wide thumbnail map. How I Was Doing It Right now, you may be thinking, “well that’s easy too, just use a little jQuery, or even just hand-write the JavaScript” and you’d be right…that’s exactly where I started. Why a Plugin? The Ultimate Guide to Writing jQuery Plugins. I have written a few articles about jQuery Plugin Development in the past which readers seem to have been interested in, but I have since then written many more plugins and have thus picked up a few more tips and tricks.

I have therefore decided to put together this more comprehensive guide on jQuery Plugin Development. I also want to note the importance of knowing how to develop jQuery plugins well as I find myself building many little custom plugins for my sites making it much easier to maintain not to mention reuse in other projects.

Anything from little pagination and nav loaders to larger handlers for many of my ajax requests. When using in conjunction with a client side framework like Backbone.js you can really develop some nice modular code and keep frameworks like Backbone doing what they do best, controlling the logical flow of your website. The Ultimate Guide to Writing jQuery Plugins. » The anatomy of a jQuery plugin: a case study Commented Out. Back to the bloging world after a while, I’ll start by writing about jQuery plugins, a subject that even though is pretty straight forward, I think not many people dare to tackle.

I’m not a particular fan of the jQuery library, but I’m not a hater either. Hey, it’s not the silver bullet for all my JS problems, but it has been a savior several times in the past. I’ll go over the basics of creating a new plugin going over the code of a plugin I wrote myself in order to understand the process a bit better: FieldSplitter. What we’re going to achieve with the plugin is the ability to grab an already existing field on a form and split it into several smaller fields, that are interconnected (jumping from one to the next is done automatically). Before writing the code, I like to think of how the public interface for the plugin will be, this way, I can start going into the plugin deeper and deeper.

Here is my idea for this plugin’s public interface: What’s the difference? Hope it helps!