Skip to content

Instantly share code, notes, and snippets.

@arth2o
Created February 17, 2016 17:01
Show Gist options
  • Save arth2o/39bc96803753ec76f6db to your computer and use it in GitHub Desktop.
Save arth2o/39bc96803753ec76f6db to your computer and use it in GitHub Desktop.
That was the last time, when I use this plugin. I have to change to select2., javascript, chosen, ajax
<select class="chosen-select" id="hello_chosen">
<option name=""></option>
</select>
$(function(){
$("#hello_chosen").chosen({
width:"400px",
allow_single_deselect: true
});
$('.chosen-search input').autocomplete({
minLength: 3,
delay: 1300,
source: function( request, response ) {
$.ajax({
url: "select.php?q="+request.term,
dataType: "json",
beforeSend: function(){ $('ul.chosen-results').empty(); $("#hello_chosen").empty(); }
}).done(function( data ) {
response( $.map( data.human, function( item ) {
$('#hello_chosen').append('<option value="blah">' + item.name + '</option>');
}));
$("#hello_chosen").trigger("chosen:updated");
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment