Created
February 17, 2016 17:01
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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