How to use Select2 with JSON via Ajax request?

for select2 v4.0.0 slightly different $(“.itemSearch”).select2({ tags: true, multiple: true, tokenSeparators: [‘,’, ‘ ‘], minimumInputLength: 2, minimumResultsForSearch: 10, ajax: { url: URL, dataType: “json”, type: “GET”, data: function (params) { var queryParameters = { term: params.term } return queryParameters; }, processResults: function (data) { return { results: $.map(data, function (item) { return { text: item.tag_value, … Read more

Is there a properly tested alternative to Select2 or Chosen? [closed]

Selectize.js is a select2 alternative I’ve been working on that has a suite of tests using a combination of testem, syn, mocha, and chai. Right now there are the following classes of tests: InteractionFunctional tests that makes sure the control behaves as if the user is using it (using syn). SetupEnsures the control can be … Read more

“query function not defined for Select2 undefined error”

Covered in this google group thread The problem was because of the extra div that was being added by the select2. Select2 had added new div with class “select2-container form-select” to wrap the select created. So the next time i loaded the function, the error was being thrown as select2 was being attached to the … Read more

How to set selected value of jQuery Select2?

SELECT2 < V4 Step #1: HTML <input name=”mySelect2″ type=”hidden” id=”mySelect2″> Step #2: Create an instance of Select2 $(“#mySelect2”).select2({ placeholder: “My Select 2”, multiple: false, minimumInputLength: 1, ajax: { url: “/elements/all”, dataType: ‘json’, quietMillis: 250, data: function(term, page) { return { q: term, }; }, results: function(data, page) { return {results: data}; }, cache: true }, … Read more

What are the differences between Chosen and Select2?

As of Select2 3.3.1, below are what’s documented in its README.md What Does Select2 Support That Chosen Does Not? Working with large datasets: Chosen requires the entire dataset to be loaded as option tags in the DOM, which limits it to working with small-ish datasets. Select2 uses a function to find results on-the-fly, which allows … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)