Tom Rogers

My personal and technology blog
Logo
 
 

StageForm (My First jQuery Plugin)

Posted on 23/10/11

in

531
Thanks!
An error occurred!

I love the JQuery javascript library just about as much as I do web development as a whole. The reason I feel that way is that it makes it so easy to improve an existing design through the addition of more contextual awareness to a web project by shielding developers from all the quirks of differing browser support for certain technologies. No small part of the reason why it has become so successful is the really robust plug-in architecture and ecosystem created around it by the community.

Some of you are probably thinking “Hang on! What even is a plug-in?” Without getting super-geeky, it is basically a way to do a lot of things to any jQuery object (thus being able to utilize functions and methods that already exist) whist keeping all the complex code for the single-track purpose that it serves out of the files where jQuery is being invoked. Maybe a better way to explain that is to use the example that, if you wanted to add AJAX validation to form elements and that required 200 lines of code, having that together with all other JS would be confusing in the future. However, if you were to invest a little more time during initial development writing that 200 lines with a plugin mindset, you could create a function that would fire off all the magic on a selected object (assuming that the plug-in is linked along with the library itself). In the file that you deal with on a day-to-day basis, this would turn those 200 lines for that function into a single one. Just in case you’re interested, it just so happens that that very example I just outlined (the first that came to mind) is actually a real plug-in.

Introducing Stageform

Admittedly, part of my motivation for creating jquery.stageform.js was that I’d never done it before and needed a purpose on which to base one. Having said that, the function that I decided on was splitting a form into stages in a semantic way and only showing one stage (elements collecting one type of data) at any time.

Getting More Information

The latest release, a working demo, feature requests and an outline of how to use all options offered by the plug-in are all available as part of the GitHub repository for this project.

Chime In and Give Your Thoughts

Comment Posting Guidance

For the benefit of every non-spambot visiting, following a recent site restructuring I have some rules with regard to etiquette for comment posters. As well as making a better experience for all, they help to distinguish real people for automatic evil machine spam. Due to this, any comment that fails to follow any one of them will be considered spam and removed as soon as possible.

With thanks, Tom

  • Coherent English must be used.
  • This form has multiple fields for a reason. Only enter a real name or nickname in the first box i.e. "Boats For Sale" wouldn't make it. Similarly, the "Website" input is a pre-determined place to post one link so there is no need to have them in the body area. This is a common technique used by spammers and marketers and, as such is not allowed.
  • Your comment must be directly related to the post to which it is a response. The idea of a post commenting system is to further the conversation that began in the given article. For instance "great post" is not a comment. My contact form can be used for suggestions or general communications.
  • Responses to other comments must be civilised.
  • No sexual reference or content is allowed.
  • Duplicate comments are a no-no.