GrassHopperPebbles.com Demos

JQuery Plugins

imMultiLineList 0.5 - Add Item

The following example demonstrates how to add a single item into the imMultiLineList plugin. Use the addItem method to add an item. The item added can be one of the following:

  1. A JSON object - The JSON must be created with the same data map options:
    {"id": "1", "address": "111 Whatever Street, This City, MD 22222"}
  2. Any string value - If the optionText is not a JSON object, the imMultiLineList plugin will use the value to create a JSON object. The db_map option optionValue can be entered with the optionText value.
    • To specify the optionValue, add the value to end of the string and separate the optionText and optionValue with a tilde (~).
      111 Whatever Street, This City, MD 22222~5

      Note: The tilde can be changed by adding the value_text_separator option.
    • If the optionValue is not part of the string, the imMultiLneList plugin will calculate the value based upon the number of items in the list.
$(document).ready( function() {
	var addressList = $("#listCntnr").imMultiLineList({
		option_map: {"optionValue": "id", "optionText": "address"},
		item_class: "multiListItem",
		item_hover_class: "multiListItemHover",
		item_select_class: 'multiListItemSelect'
	});
	addressList.addItems('assets/js/jquery/immultilinelist/address.php');
	$('#theButton').click(function() {
		addressList.addItem($('#theText').val());
	});
});	

View the source for this page to see how to setup the plugin. For documentation about the imMultiLineList plugin, view the blog post.



Tags

, , ,