jquery-select2

Select2 produces rough scrolling on mobile

与世无争的帅哥 提交于 2019-12-07 11:35:29
I'm testing the Select2 jQuery component on an iPhone, and all I did was open their demo website: https://select2.org/getting-started/basic-usage If you test their State example on a phone, scrolling doesn't respond to pressure and doesn't fade smoothly. It's a rough line scroll. When you move your thumb, the lines don't fade in and out. On the other hand, on a desktop the scrolling/fading works great. It responds gracefully to mouse-wheel scrolls. Just wondering has anyone noticed this? EDIT Looks like iOS (unlike Android) requires <div style="-webkit-overflow-scrolling: touch;"> for smooth

Wrap selected text with Select2

╄→гoц情女王★ 提交于 2019-12-07 10:29:56
问题 How can I get the selected text in Select2 to wrap instead of using an ellipsis? The option items wrap, but I'd like the input field to be able to expand down instead of over. Here's an example : $('.select2').select2(); <link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.css" rel="stylesheet"/> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.js"></script> <select class=

Select2 Custom Matcher for Non-Adjacent Keywords

六月ゝ 毕业季﹏ 提交于 2019-12-07 10:29:19
问题 I use Select2 in my app to allow for searching a dropdown with about 1200 options. I am currently making use of the default implementation of Select2's matcher, which works well as long as keywords are adjacent in the search results: function(term, text) { return text.toUpperCase().indexOf(term.toUpperCase())>=0; } For example, a search for 'stackoverflow question' returns option 'Stackoverflow question about Select2' I would however else like the matcher to return results based on non

Select2 jQuery Plugin: Is there a way to sort a list of tags alphabetically?

巧了我就是萌 提交于 2019-12-07 08:57:01
问题 I'm using Select2 plugin (http://ivaynberg.github.io/select2/) and as you can see by the list of tags I have in the screenshot, they aren't listed alphabetically and I'd like to be able to do so. EDIT: This is what I currently have, but instead of query, I want to sort the data (@appTags) via 'text', not 'id': scope.find('input[name=noun]').select2({ data: @appTags, sortResults: function(results, container, query) { if (query.term) { return results.sort(); } return results; } }); Screenshots

Creating new tags in a Select2 tag textarea

假如想象 提交于 2019-12-07 06:10:58
问题 I have an input (textarea) that has Select2's tags applied to it. So when a user types in the name of an item that exists in my data base, it shows a list of matching items and the user can select one and a tag is created. Here is my code so far for basic tag functionality: $('#usualSuppliers').select2({ placeholder: "Usual suppliers...", minimumInputLength: 1, multiple: true, id: function(e) { return e.id + ":" + e.name; }, ajax: { url: ROOT + 'Ajax', dataType: 'json', type: 'POST', data:

jQuery select2 breaks as soon as I add tags

纵然是瞬间 提交于 2019-12-07 06:06:02
问题 As soon as I add tags to my jQuery select2 it breaks and reverts back to the normal HTML select box. Here is my code (exactly like this example): $(document).ready(function() { $("#tags").select2({tags:["red", "green", "blue"]}); }); If I remove the tags part it works again: $(document).ready(function() { $("#tags").select2(); }); 回答1: If you look in your javascript console you will see the following error message: Error: Option 'tags' is not allowed for Select2 when attached to a <select>

Additional info below the main text on select option

一世执手 提交于 2019-12-07 06:04:41
问题 I used select2 to produce my select option list like the snippet below. $(function(){ $(".select2").select2(); }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.4/css/select2.min.css" rel="stylesheet"/> <div class="form-group"> <label>Minimal</label> <select class="form-control select2" style="width: 100%;"> <option selected="selected">Alabama</option> <option>Alaska</option> <option

Select2 onselect an option will select all other option

南楼画角 提交于 2019-12-07 03:52:31
问题 I have a select 2 provided in this JSFIDDLE. How can I onselect an option call All it will select all of the option inside that select field except for itself, meaning the All option is more like a Select All button. and deselecting the All . will deselect all option. I provide the same code from the jsfiddle below : HTML : <select class="parent_filter_select2 pull-right" id="parent_filter_select2" multiple="multiple" name="select_project" style="width: 300px;"> <option value="all">All<

How to get all the values in a Select2 dropdown?

你离开我真会死。 提交于 2019-12-07 02:20:04
问题 How can we get all the elements that are in the jQuery Select2 dropdown plugin. I have applied Select2 to a input type = hidden, and then populated it using Ajax. Now at one instance I need to get all the values that are appearing in the dropdown. Here is a input field. <input type="hidden" id="individualsfront" name="individualsfront" style="width:240px" value="" data-spy="scroll" required /> and to this input field I have applied this $("#individualsfront").select2({ multiple: true, query:

Select2 auto trigger event change

喜夏-厌秋 提交于 2019-12-07 00:37:58
问题 I have 4 select boxes, when I change the first one do some stuff like empty, append and SET the new value for the next one. Because I use select2 just can set it using $.select2('val','value'); Just that command trigger the change event on the other select and do cascade of changes. Notice that .empty() and append() wont trigger (and i like that), even .val() should not trigger it, but when ure using select2 you can't access the new val using that. Code here: function anidado(selectorOrigen