Pelicans Are Evil

23 May, 2008
 

AddToList Jquery extension

AddToList is the plugin I wrote to solve a very simple problem: being able to add new <option> items to a select list.

The reason behind wanting this functionality is also simple: If you have a <select> list thats generated from a database, you'll be able to add new items to this list without having to break your current work flow. It's really anoying when you have to stop what your doing, to add more items to your list of options because they're currently not created. This plugin makes the process of adding a new item, and selecting that new item (automatically) easier

Being a jquery plugin, there's a few options i've included to help you out.

triggerValue: allows you to set a value from the list that will trigger the form opening action. This means you could create a dummy <option value="-1">add new</option> and use -1 as the trigger value. You can also trigger the open form using an event.

form: this is a jquery selector string that specifies the dom element for the form that will open up when the trigger value is detected.

Those are the two main options (there's others, but they're not that important).

The plugin is not released. It's in a very rough form at the moment. I need to test, clean it up, and trigger some more useful events (currently theres form-open, form-close, form-success, form-success-inserted, form-fail that you can tap into using .trigger or .bind).

Once I get a 1.0 version ready & documented I'll post it to http://plugins.jquery.com

Labels: , , , , ,