| 1 |
<!DOCTYPE html> |
| 2 |
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--> |
| 3 |
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]--> |
| 4 |
<!--[if IE 8]><html class="no-js lt-ie9"><![endif]--> |
| 5 |
<!--[if gt IE 8]><!--><html class="no-js"><!--<![endif]--> |
| 6 |
<head> |
| 7 |
<meta charset="utf-8"> |
| 8 |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> |
| 9 |
<title>Selectize.js Demo</title> |
| 10 |
<meta name="description" content=""> |
| 11 |
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"> |
| 12 |
<link rel="stylesheet" href="css/normalize.css"> |
| 13 |
<link rel="stylesheet" href="css/stylesheet.css"> |
| 14 |
<!--[if IE 8]><script src="js/es5.js"></script><![endif]--> |
| 15 |
<script src="js/jquery.min.js"></script> |
| 16 |
<script src="../dist/js/standalone/selectize.js"></script> |
| 17 |
<script src="js/index.js"></script> |
| 18 |
</head> |
| 19 |
<body> |
| 20 |
<div id="wrapper"> |
| 21 |
<h1>Selectize.js</h1> |
| 22 |
<div class="demo"> |
| 23 |
<h2>API</h2> |
| 24 |
<p>Examples of how to interact with the control programmatically.</p> |
| 25 |
<div class="control-group"> |
| 26 |
<label for="select-tools">Tools:</label> |
| 27 |
<select id="select-tools" multiple placeholder="Pick a tool..."></select> |
| 28 |
</div> |
| 29 |
<div class="buttons"> |
| 30 |
<input type="button" value="clear()" id="button-clear"> |
| 31 |
<input type="button" value="clearOptions()" id="button-clearoptions"> |
| 32 |
<input type="button" value="addOption()" id="button-addoption"> |
| 33 |
<input type="button" value="addItem()" id="button-additem"> |
| 34 |
<input type="button" value="setValue()" id="button-setvalue"> |
| 35 |
</div> |
| 36 |
<script> |
| 37 |
var $select = $('#select-tools').selectize({ |
| 38 |
maxItems: null, |
| 39 |
valueField: 'id', |
| 40 |
labelField: 'title', |
| 41 |
searchField: 'title', |
| 42 |
options: [ |
| 43 |
{id: 1, title: 'Spectrometer', url: 'http://en.wikipedia.org/wiki/Spectrometers'}, |
| 44 |
{id: 2, title: 'Star Chart', url: 'http://en.wikipedia.org/wiki/Star_chart'}, |
| 45 |
{id: 3, title: 'Electrical Tape', url: 'http://en.wikipedia.org/wiki/Electrical_tape'} |
| 46 |
], |
| 47 |
create: false |
| 48 |
}); |
| 49 |
|
| 50 |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 51 |
|
| 52 |
var control = $select[0].selectize; |
| 53 |
|
| 54 |
$('#button-clear').on('click', function() { |
| 55 |
control.clear(); |
| 56 |
}); |
| 57 |
|
| 58 |
$('#button-clearoptions').on('click', function() { |
| 59 |
control.clearOptions(); |
| 60 |
}); |
| 61 |
|
| 62 |
$('#button-addoption').on('click', function() { |
| 63 |
control.addOption({ |
| 64 |
id: 4, |
| 65 |
title: 'Something New', |
| 66 |
url: 'http://google.com' |
| 67 |
}); |
| 68 |
}); |
| 69 |
|
| 70 |
$('#button-additem').on('click', function() { |
| 71 |
control.addItem(2); |
| 72 |
}); |
| 73 |
|
| 74 |
$('#button-setvalue').on('click', function() { |
| 75 |
control.setValue([2, 3]); |
| 76 |
}); |
| 77 |
</script> |
| 78 |
</div> |
| 79 |
</div> |
| 80 |
</body> |
| 81 |
</html> |