Skip to content

Instantly share code, notes, and snippets.

@chetans9
Created November 12, 2017 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chetans9/4f68d8d4b7d822d50a9d6d84b785f3da to your computer and use it in GitHub Desktop.
Save chetans9/4f68d8d4b7d822d50a9d6d84b785f3da to your computer and use it in GitHub Desktop.
Select2 Remote configuration for dropdown suggestion
//JS side Configuration
$("#user_emails").select2({
ajax: {
url:"/api/yourown",
dataType: 'json',
delay: 250,
data: function (params) {
return {
q: params.term, // search term
};
},
processResults: function (data) {
return data
},
cache: true
},
minimumInputLength: 2,
});
//JSON response Format required :
//{results: [{id: 23,text: "chetan@live.com"},{id:26,text : "chetan@gmail.com"}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment