Skip to content

A collection of methods to handle HTML's SELECT elements.

Notifications You must be signed in to change notification settings

antoniom/jquery-select-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jQuery Select Utils

A collection of methods to handle HTML's SELECT elements.

Build Status

Installation

bower install jquery-select-utils

Getting Started

Download the production version or the development version.

In your web page:

<script src="jquery.js"></script>
<script src="dist/jquery-select-utils.min.js"></script>
<script>
  jQuery(function ($) {
  	// Empty a select list
    $('your-select-element').selectUtils('setEmpty');
    // Empty the list and leave a prompt
    $('your-select-element').selectUtils('setEmpty', 'default prompt'); 
    // Populate from an object list (the last argument stands for the prompt and is optional)
    $('your-select-element').selectUtils('populateFromObjectList', [{id: 1, name: "Name 1"}, {id: 2, name: "Name 2"}], 'id', 'name', 'Please Select');
    // Populate from an array. The array key is used for the lists value. The last argument is used in order to add an offset from the array's key.
    $('your-select-element').selectUtils('populateFromArray', ["DATA 1", "DATA 2", "DATA 3", "DATA 4"], 'Please Select', 1);

  });
</script>

License

MIT © Antonis Balasas

About

A collection of methods to handle HTML's SELECT elements.

Resources

Stars

Watchers

Forks

Packages

No packages published