JQuery.AddToList

Documentation

.addToList(options);

Sets up and binds the nessacary events for the AddToList plugin. It requires an Options Object for the first parameter.

$('select').addToList();

Options Object

form

Required

The jquery selector string to your custom form element.

AddToList will automatically hide this form element if it's visible (to give it a popup effect). The element you specific must either be a <form> or contain a <form> within it's descendant's.

{form: '.form'}

dataHandler

Required

A callback function that will handle a successful ajax request. It is provided with a single argument. This argument contains the data response from ajax (thus it's important to correctly set your dataType).

This callback function MUST return an object that contains a value & label property. AddToList will use these 2 properties to create the new <option> element.

.addToList({
	dataType: 'json',
	dataHandler: function(data) {
		return {
			value: data.value,
			label: data.label
		};
	}
});

triggerValue

A 'value' from within the list that will trigger the 'form-open' event. Defaults to -1.

<select name="reference">
<option value="my-custom-trigger">Add New Item<option>
....
</select>

....
$('select').addToList({triggerValue: 'my-custom-trigger'});

submitURL

Currently not used. Interface for future feature

dataType

This is the dataType the ajax request will use. This option is passed straight to the ajax call

Allowed Values

insertPosition

Determines the position of the a newly created item.

It accepts the following values

Allowed Values
Back to AddToList