Submit your widget

jquery select expander - make select dom by json file

Created 11 years ago   Views 5901   downloads 1568    Author mgyarmathy
jquery select expander - make select dom  by json file
View DemoDownload
21
Share |

Usage

Download and copy the plugin + json data into your js/ folder. (make sure the data/ folder is in the same directory as the plugin)

Drop in the plugin after your jQuery include:

<script src="js/jquery.js"></script>
<script src="js/jquery-select-expander.min.js"></script>

Call the plugin after the DOM is ready:

$(document).ready(function(){
    $('select').selectExpander();
});

Specify the options for your select elements using the data-from attribute:

<select data-from="country"></select>

The data-from attribute specifies the name of the json file contained in the data/ folder. This plugin comes with json files for states and countries out of the box. Feel free to modify them as you please.

If you want to add your own json file, follow this format:

{
    "<option-value>": "<option-label>",
    "<option-value>": "<option-label>",
    "<option-value>": "<option-label>"
}

Create a useful set of options? Please make a pull request to add it to my collection!