Skip to content

Instantly share code, notes, and snippets.

Created October 16, 2014 19:48
Show Gist options
  • Save anonymous/a355598b1bc069d0d3a1 to your computer and use it in GitHub Desktop.
Save anonymous/a355598b1bc069d0d3a1 to your computer and use it in GitHub Desktop.
[add your bin description] // source http://jsbin.com/titevehixaro/1
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<meta charset="utf-8">
<title>JS Bin</title>
<select id="regiones" class="searchable" multiple="multiple" name="region" size="15px" style="width: 100px">
<optgroup label="Father1">
<option>Son1.1</option>
<option>Son1.2</option>
<option>Son1.3</option>
<option>Son1.4</option>
</optgroup>
<optgroup label="Father2">
<option>Son2.1</option>
<option>Son2.2</option>
<option>Son2.3</option>
<option>Son2.4</option>
</optgroup>
<optgroup label="Father3">
<option>Son3.1</option>
<option>Son3.2</option>
<option>Son3.3</option>
<option>Son3.4</option>
</optgroup>
</select>
</head>
<body>
<script id="jsbin-javascript">
$(document).ready(function() {
$('#regiones').multiSelect({
selectableOptgroup: true,
selectableHeader: "<input type='text' size='15px' class='search-input' autocomplete='on' placeholder='try \"12\"'>",
selectionHeader: "<input type='text' class='search-input' autocomplete='on' placeholder='try \"4\"'>",
afterInit: function(ms){
var that = this,
$selectableSearch = that.$selectableUl.prev(),
$selectionSearch = that.$selectionUl.prev(),
selectableSearchString = '#'+that.$container.attr('id')+'.ms-optgroup-label:not(.ms-selected), .ms-elem-selectable:not(.ms-selected)',
selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
.on('keydown', function(e){
if (e.which === 40){
that.$selectableUl.focus();
return false;
}
});
that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
.on('keydown', function(e){
if (e.which == 40){
that.$selectionUl.focus();
return false;
}
});
},afterSelect: function(){
this.qs1.cache();
this.qs2.cache();
},
afterDeselect: function(){
this.qs1.cache();
this.qs2.cache();
}
});
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">$(document).ready(function() {
$('#regiones').multiSelect({
selectableOptgroup: true,
selectableHeader: "<input type='text' size='15px' class='search-input' autocomplete='on' placeholder='try \"12\"'>",
selectionHeader: "<input type='text' class='search-input' autocomplete='on' placeholder='try \"4\"'>",
afterInit: function(ms){
var that = this,
$selectableSearch = that.$selectableUl.prev(),
$selectionSearch = that.$selectionUl.prev(),
selectableSearchString = '#'+that.$container.attr('id')+'.ms-optgroup-label:not(.ms-selected), .ms-elem-selectable:not(.ms-selected)',
selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
.on('keydown', function(e){
if (e.which === 40){
that.$selectableUl.focus();
return false;
}
});
that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
.on('keydown', function(e){
if (e.which == 40){
that.$selectionUl.focus();
return false;
}
});
},afterSelect: function(){
this.qs1.cache();
this.qs2.cache();
},
afterDeselect: function(){
this.qs1.cache();
this.qs2.cache();
}
});
});</script></body>
</html>
$(document).ready(function() {
$('#regiones').multiSelect({
selectableOptgroup: true,
selectableHeader: "<input type='text' size='15px' class='search-input' autocomplete='on' placeholder='try \"12\"'>",
selectionHeader: "<input type='text' class='search-input' autocomplete='on' placeholder='try \"4\"'>",
afterInit: function(ms){
var that = this,
$selectableSearch = that.$selectableUl.prev(),
$selectionSearch = that.$selectionUl.prev(),
selectableSearchString = '#'+that.$container.attr('id')+'.ms-optgroup-label:not(.ms-selected), .ms-elem-selectable:not(.ms-selected)',
selectionSearchString = '#'+that.$container.attr('id')+' .ms-elem-selection.ms-selected';
that.qs1 = $selectableSearch.quicksearch(selectableSearchString)
.on('keydown', function(e){
if (e.which === 40){
that.$selectableUl.focus();
return false;
}
});
that.qs2 = $selectionSearch.quicksearch(selectionSearchString)
.on('keydown', function(e){
if (e.which == 40){
that.$selectionUl.focus();
return false;
}
});
},afterSelect: function(){
this.qs1.cache();
this.qs2.cache();
},
afterDeselect: function(){
this.qs1.cache();
this.qs2.cache();
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment