1. INCLUDE CSS AND JS FILES
<link rel="stylesheet" href="css/asChoice.css">
<script src="js/vendor/jquery-1.9.1.min.js"></script>
<script src="../src/jquery-asChoice.js"></script>
2. HTML
<select class="select" multiple="multiple">
<option value ="default" selected="selected">default</option>
<option value ="on">on</option>
<option value="off">off</option>
</select>
3. JAVASCRIPT
$('.select').asChoice({
skin: null,
status: {
a: {
text: 'on',
icon: 'icon-1'
},
b: {
text: 'off',
icon: 'icon-2'
},
c: {
text: 'default',
icon: 'icon-3'
}
},
multiple: false,
value: ['default'],
namespace: 'asChoice'
});
4. OPTIONS
//Optional property, choose asChoice's skin, more skins is coming soon
skin: null,
//Optional property, set the status of elements,for example
//<code>a:{text: 'on',icon: 'icon1'}</code> means the element's
//value is 'a',the text is 'on' and it will add a icon'
status: a:{
text: 'on',
icon: 'icon-1'
},
b:{
text: 'off',
icon: 'icon-2'
},
c:{
text: 'default',
icon: 'icon-3'
},
//Optional property, set the value for element when asChoice initilize
value: ['default'],
//callback when asChoice's value change
Onchange: function(){}
5. METHODS
// set element's value and status
$(".select").asChoice("set");
// set enable true
$(".select").asChoice("enable");
// set enable false
$(".select").asChoice("disable");
6. EVENTS
-
change: trigger when element set afresh
how to use event:
$(document).on('change', function(event,instance) {
// instance means current asChoice instance
// some stuff
});