Api Demo

This example shows how to use select2 to create a subject autosuggest.

A list of accepted url parameters can be found here

View Source

Normal select

Binded selects


The select2 class on the input is to mark that input to be initialized a select2 by the initselect.js file. data-action is added to specify the api endpoint. By default the name is used as data-action. Data-query is aditional query parameters to add to the select. In the example above data-query="includeonly=id,text,label&div=1,2,5,7" we are includingonly the columns id,text,label in the response. Label is specific to subject at this point.Label is used as the dropdown text while text is used when a item is selected. We have included the parameter div with values 1,2,5,7. This limits the response to only subjects matching those divisions

The Javascript/jQuery to make it work

The initselect file

If you follow the HTML guidelines laid above and include the above scripts on your page you can use any bugwood api select 2 friendly response on your page on a select2 change it will call the reload function.