Skip to content

Instantly share code, notes, and snippets.

@nauvalidzi
Created July 14, 2023 04:34
Show Gist options
  • Select an option

  • Save nauvalidzi/61de7ada97f0e55df075074a52b47d1b to your computer and use it in GitHub Desktop.

Select an option

Save nauvalidzi/61de7ada97f0e55df075074a52b47d1b to your computer and use it in GitHub Desktop.
// source = https://github.com/select2/select2
$('#select2').select2({
placeholder: 'Select the product',
ajax: {
url: "https://dummyjson.com/products",
processResults: function ({data}) {
return {
results: $.map(data, function (item) {
return {
id: item.id,
text: item.title
}
})
}
}
},
language: {
searching: function() {
return 'Loading ...';
}
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment