jquery-select2-4

Select2 4 custom data adapter

回眸只為那壹抹淺笑 提交于 2020-01-22 14:38:10
问题 I am trying to create a custom data adapter according to an example here: http://select2.github.io/announcements-4.0.html#query-to-data-adapter. How can I move the line that creates the select2 control outside the function with definition of DataAdapter (see the code below)? <!DOCTYPE html> <head> <title></title> <link href="select2.css" rel="stylesheet" /> <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.js"></script> <script type="text/javascript" src="select2.full.js

How to clone select2 v4 Ajax

£可爱£侵袭症+ 提交于 2020-01-14 03:11:28
问题 I am attempting to do an AJAX call with the Select2 ver4 jquery plugin and Using Loading remote data of Select2 sample page I am trying to clone a select which contains select2 tool. But select2 dropdown disabled when cloning. HTML CODE <tr> <td> <select class="js-example-data-ajax" id="sel1"> </select> <button type="button" class="addline">Add Line</button> </td> </tr> jQuery CODE $.fn.select2.amd.require( ["select2/core", "select2/utils", "select2/compat/matcher"], function (Select2, Utils,

Select2 - Sorting results by query

拥有回忆 提交于 2020-01-10 13:11:28
问题 I'm using Select2 version 4.0.0. If my results contain multiple words, and the user enters one of those words, I want to display the results sorted by where the entered word is within the result. For example, a user enters "apple", and my results are: "banana orange apple" "banana apple orange" "apple banana orange" Then "apple banana orange" should appear first in the list of select2 results, because that is the result in which "apple" appears earliest within the result. I don't care so much

Select2 - Sorting results by query

可紊 提交于 2020-01-10 13:11:10
问题 I'm using Select2 version 4.0.0. If my results contain multiple words, and the user enters one of those words, I want to display the results sorted by where the entered word is within the result. For example, a user enters "apple", and my results are: "banana orange apple" "banana apple orange" "apple banana orange" Then "apple banana orange" should appear first in the list of select2 results, because that is the result in which "apple" appears earliest within the result. I don't care so much

Yii2: How to change font-family of Select2 widget

爱⌒轻易说出口 提交于 2020-01-06 07:57:11
问题 I have a select2 widget and I need to change its font-family. <?= $form->field($model, 'my_number') ->widget(Select2::classname(), [ 'items' => ['One' => 'One', 'Two' => 'Two', 'Three' => 'Three'], 'class' => 'form-control', ]) ?> Bootstrap doesn't have a class to change it so I think I need to change its style. 回答1: you can add style to it like follows: <?= $form->field($model, 'my_number') ->widget(Select2::classname(), [ 'items' => ['One' => 'One', 'Two' => 'Two', 'Three' => 'Three'],

Yii2: How to change font-family of Select2 widget

痞子三分冷 提交于 2020-01-06 07:56:10
问题 I have a select2 widget and I need to change its font-family. <?= $form->field($model, 'my_number') ->widget(Select2::classname(), [ 'items' => ['One' => 'One', 'Two' => 'Two', 'Three' => 'Three'], 'class' => 'form-control', ]) ?> Bootstrap doesn't have a class to change it so I think I need to change its style. 回答1: you can add style to it like follows: <?= $form->field($model, 'my_number') ->widget(Select2::classname(), [ 'items' => ['One' => 'One', 'Two' => 'Two', 'Three' => 'Three'],

Strike out the text for the options instead of disabling them - select2 v4

偶尔善良 提交于 2020-01-05 05:46:27
问题 I'm trying to show the strikeout text for the options instead of disabling them so there should be a possibility to select them again. I tried adding css like below: $(this).css('text-decoration','line-through'); $(this).css('background','#ccc'); But none of them did not work and tried even adding some class to the option, make them styled with text-decoration . Here is code snippet $('.employee-dropdown').select2(); $(".employee-dropdown").on('change', function(e) { $('.employee-dropdown')

select2 display not updating label text but value is changing

北战南征 提交于 2020-01-04 06:15:13
问题 I am using select2 v4.0.3 along with JQuery. I initialize my selectors as: $("#datatype").select2({ theme: "classic" }); $("#unit").select2({ theme: "classic" }); Then I want to detect a change on #datatype and change the value of #unit which I do as follows: $("#datatype").on('select2:select',function () { $("#unit").val('21'); //udpate unit type to be 'none' }); The problem is that the value of #unit is getting set to 21 but the displayed label for that selector is not updating. Any

selec2 search - Return no results found message if a specific criteria didnt match

蹲街弑〆低调 提交于 2019-12-25 16:43:44
问题 I am using select2 4.0.3 for search drop down. As per my understanding its default functionality is not to match with the start of entries the drop down have. So I have implemented the below given code function matchStart(params, data) { params.term = params.term || ''; if (data.text.toUpperCase().indexOf(params.term.toUpperCase()) == 0) { return data; } return false; } $("select").select2({ placeholder : "Input country name or select region", matcher : function (params, data) { return

selec2 search - Return no results found message if a specific criteria didnt match

橙三吉。 提交于 2019-12-25 16:43:02
问题 I am using select2 4.0.3 for search drop down. As per my understanding its default functionality is not to match with the start of entries the drop down have. So I have implemented the below given code function matchStart(params, data) { params.term = params.term || ''; if (data.text.toUpperCase().indexOf(params.term.toUpperCase()) == 0) { return data; } return false; } $("select").select2({ placeholder : "Input country name or select region", matcher : function (params, data) { return