jquery-select2

Using SELECT2 4.0.0 with infinite Data and filter

て烟熏妆下的殇ゞ 提交于 2019-12-03 12:34:57
问题 I'm using Select2 now since 2 years and I really enjoy all dev made. however, version 3.5.x has his limit, so I'm moving to version 4.0, which give me headaches! For your record, I'm using Select2 with large table (> 10.000 entries), so AJAX & infinite data (page set to 50 items). With version 3.5.2, I can reproduce the underline match when searching for data (using formatSelection and query.term ). Any idea how to make it with version 4.0.0 (function templateResult only passes result and not

Can't select item in list created by ui-select2

孤者浪人 提交于 2019-12-03 12:16:16
In my HTML I have this line: <input ng-change="privChanged()" ng-model="selectedPriv" ui-select2="privsSelect2options"></input> and the privsSelect2options function: $scope.privsSelect2options = { placeholder: "Wybierz privo", allowClear:true, minimumInputLength: function(){return 3;}, formatInputTooShort: function (input, min) {return "Wprowadź conajmniej " + min + " znaki.";}, formatSearching: function () { return "Wyszukiwanie..."; }, formatNoMatches: function () { return "Nie znaleziono pasujących województw."; }, query: function (query) { query.callback( {results: $filter('filter')($scope

Allow to add a new value in a choice Field Type

早过忘川 提交于 2019-12-03 12:11:11
问题 I use Form Component and have a choice Field Type on a form which is rendered to a select field. On a client-side I use select2 plugin which initializes the select with the setting tags: true wich allows to add a new value in it. But if I add a new value then a validation on a server will fail with error This value is not valid. because the new value isn't in a choice list. Is there a way to allow adding of a new value to choice a Field Type? 回答1: The problem is in a choice transformer, which

select2 plugin and jquery ui modal dialogs

牧云@^-^@ 提交于 2019-12-03 11:52:57
I am using the Select2 plugin, but the built in search functionality doesn't work when the plugin is used with a jQuery modal dialog. I have a fiddle that shows the problem at... http://jsfiddle.net/jeljeljel/s3AFx/ Notice the Search box will not accept the focus. There is supposed to be a workaround with the _allowInteraction event ( http://api.jqueryui.com/dialog/#method-_allowInteraction ), but it isn't working for me. Can anyone help to see how to make this Fiddle work? Also, this SO post ( select2 plugin works fine when not inside a jquery modal dialog ) discusses the same issue, but the

How to add HTML content at select2 dropdown box

浪尽此生 提交于 2019-12-03 11:18:30
I've used Select2 plugin for tag input. Here is the fiddle of my basic work . I need showing "used number" of each options/tags at dropdown box like this way: I've created a class for that number in my CSS ( .used-number ). But, I don't understand how can I add that number for each options at my HTML file. Is there a way to add those something like this(or any other way): $(".tag").select2({ data:[{tag: 'red',text:'3',className: 'used-number'},{tag: 'green',text:'12',className: 'used-number'},{tag: 'blue',text:'5', className: 'used-number'},{tag: 'black',text:'7'}] }); }); The tags array must

How to remove selected option from the option list in select2 multiselect and show selected options in the order they are selected

天大地大妈咪最大 提交于 2019-12-03 11:00:47
问题 I have select2 multi select field in my form where I want to remove the selected option from the dropdown list after it is selected and again add it to the list if it is removed from the list. And also the added items should be in the same order as they selected. The current select2 (4.0) is not removing the selected the items and and it is showing the selected items in the order they appear in the drop down list, not in the order they are selected. $(document).ready(function(){ $('

Dynamic select2 not firing change event

☆樱花仙子☆ 提交于 2019-12-03 09:37:20
I have a form with a couple of selects inside. I'm applying the select2 jquery plugin over those selects like this: $("select.company_select, select.positions_select").select2(); The select's work fine, but I have this code to autosubmit my form (I have the autosubmit class on the form tag). var currentData; $('.autosubmit input, .autosubmit select, .autosubmit textarea').live('focus', function () { currentData = $(this).val(); }); $('.autosubmit input, .autosubmit select, .autosubmit textarea').live('change', function () { console.log('autosubmiting...'); var $this = $(this); if (!currentData

Select2 dropdown allow new values by user when user types

安稳与你 提交于 2019-12-03 07:57:19
The select2 component can be configured to accept new values, as ask in Select2 dropdown but allow new values by user? And you can see it at: http://jsfiddle.net/pHSdP/646/ the code is as below: $("#tags").select2({ createSearchChoice: function (term, data) { if ($(data).filter(function () { return this.text.localeCompare(term) === 0; }).length === 0) { return { id: term, text: term }; } }, multiple: false, data: [{ id: 0, text: 'story' }, { id: 1, text: 'bug' }, { id: 2, text: 'task' }] }); The problem is that the new value is only added to the list if you enter new value and press enter, or

Set data in Select2 after insert with AJAX

天涯浪子 提交于 2019-12-03 07:17:49
i'm using the Select2 with AJAX (the code below): $(".select2-ajax").select2({ placeholder: "Search user", minimumInputLength: 1, ajax: { url: $('#url-search-client').val(), dataType: 'json', type: 'post', data: function (term, page) { return { filter: term }; }, results: function (data, page) { return {results: data}; } }, width : '50%', formatInputTooShort: function () {return 'Informe mais caracteres'; }, formatResult: formatResultSelectAjax, // omitted for brevity, see the source of this page formatSelection: formatSelectAjaxValue, // omitted for brevity, see the source of this page

javascript select2 allowed tags

别等时光非礼了梦想. 提交于 2019-12-03 06:01:16
I need to allow users select ONLY allowed tags in select. Currently I have that: $("input#id_txtcolor").select2({tags:["red", "green", "blue"]}); Can you help me please with that? as of 3.3 you can specify your own createSearchChoice when using tags that will always return null, thus preventing the default choice from being created. $().select2({ createSearchChoice: function() { return null; }, tags:... }); Sometimes we developer don't use our 7th sense that is common sense also happened with me struggled for 2 hours then it clicked my sense.. if you want user to select only allowed values