Created
November 12, 2017 11:45
-
-
Save chetans9/4f68d8d4b7d822d50a9d6d84b785f3da to your computer and use it in GitHub Desktop.
Select2 Remote configuration for dropdown suggestion
This file contains 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
//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: "[email protected]"},{id:26,text : "[email protected]"}]} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment