select2
HTML
<link rel="stylesheet" href="http://ivaynberg.github.com/select2/select2-3.3.1/select2.css">
<script src="http://ivaynberg.github.com/select2/select2-3.3.1/select2.js"></script>
<select id="select">
<option selected>Selected</option>
<option>Not selected</option>
</select>
<div id="console"></div>
CSS
body {
font-family: sans-serif;
}
ul {
padding: 0;
}
.info {
color: #00f;
font-weight: bold;
font-size: 10px;
float: right;
}
.info:hover {
text-decoration: underline;
}
JavaScript
function onSelectChange(){
alert('changed');
};
var select2 = $("#select").select2().data('select2');
select2.onSelect = (function(fn) {
return function(data, options) {
var target;
if (options != null) {
target = $(options.target);
}
if (target) {
onSelectChange();
return fn.apply(this, arguments);
}
}
})(select2.onSelect);