Super Sale Limited Time 50% OFF for All-Access Plans
Save 50% Now

Select2 Ajax support.


Hi keenthemes,

I create a backend API for a drug search checkup, and hook it with select2 and search using select2 Ajax options, everything works great, except when I seach and select in a drop down, it wont validated the result in the select2 input box = meaning nothing happend if you click on the dropdown selection.

here's the screenshots : <a>

refered to those online ressources :
1 -
2 -

here's a result of an "pa" search result json api result format :
<a>


Here's my js :


$("#id_prescriptiondetail-0-drug").select2({
minimumInputLength: 2,
minimumResultsForSearch: 20,
//placeholder: "Select a state",
placeholder: {
id: "-1", // the value of the option
text: "Search a drug"
},
allowClear: true,
cache: true,
ajax: {
url: "
type: "get",
dataType: "json",
delay: 250,
data: function(params) {
return {
searchTerm: params.term // search term
};
},
processResults: function(response) {
return {
results: response
};
}
}
});



Can you please supply a Select2 Ajax capabilities in the next update, please.

thank you.


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (4)


Hi Keenthemes, forget about, I dropped the select2 ajax route (now).

went Tagify select mode route.

hope the ajax will be not that hard.

thank you.



Hi,

Noted, we will have a look at this. It is in our to-do list since your initial request.

Regards



Thank you Sean.



refered code number 2 is this one :


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(