Submit your widget

jquery select expander - make select dom by json file

Created 10 years ago   Views 5528   downloads 1405    Author mgyarmathy
jquery select expander - make select dom  by json file
View DemoDownload
18
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!