jquery-select2

Select2 Dependent dropdown lists

ぐ巨炮叔叔 提交于 2019-12-20 14:21:19
问题 I am trying to use the Select2 plugin to have 4 dropdown lists that depend on each other. I have struggled to find the right way to update the data that loads the options in. My goal is to load the new data via ajax, but once I have it in the client I am unable to add the new data to the select list. The code I have tried is here: $(#"a3").select2({ placeholder: "select an item", allowClear: true}).on("change", function (e) { var results = $.get("url?id=2", function (data, textStatus, jqXHR)

Setting initial values of Angular-UI Select2 multiple directive

心不动则不痛 提交于 2019-12-20 11:31:39
问题 I have a select2 directive for a multiple select of countries with a custom query to grab the data: // Directive <input ng-model="filters.countries" ui-select2="filters.countryOptions" data-placeholder="Choose a country..."> // filters.countryOptions { multiple: true, query: function() { get_list_of_countries(); } } // Formatted data from remote source [ {id: 'US', text: 'United States'}, {id: 'CA', text: 'Canada'} ... ] I'm trying to set the initially selected values in my controller using:

Setting initial values of Angular-UI Select2 multiple directive

偶尔善良 提交于 2019-12-20 11:31:12
问题 I have a select2 directive for a multiple select of countries with a custom query to grab the data: // Directive <input ng-model="filters.countries" ui-select2="filters.countryOptions" data-placeholder="Choose a country..."> // filters.countryOptions { multiple: true, query: function() { get_list_of_countries(); } } // Formatted data from remote source [ {id: 'US', text: 'United States'}, {id: 'CA', text: 'Canada'} ... ] I'm trying to set the initially selected values in my controller using:

Polymer select2 element

£可爱£侵袭症+ 提交于 2019-12-20 02:54:53
问题 I am attempting to wrap the great select2 jquery widget (https://github.com/ivaynberg/select2) in a Polymer element for easy reuse. I was able to get the select initialized correctly, but am running into issues after initialization. Specifically, when clicking the select to open it a type error is thrown in the select2 script when positioning the pop over. Here is a repo with the failing implementation: https://github.com/ivelander/x-select2 Has anyone had good success integrating Polymer

jquery select2 plugin how to get only the result 'myString%'

大兔子大兔子 提交于 2019-12-20 02:37:23
问题 i'm using the jquery-select2 plugin but i'm wondering how can i get only results that begins with the typed keyword ( like 'myString%') 回答1: The documentation actually provides an example for that: $("select").select2({ matcher: function(term, text) { return text.toUpperCase().indexOf(term.toUpperCase())==0; } }); The above matcher is case-insensitive, for case-sensitive remove both .toUpperCase() calls. 来源: https://stackoverflow.com/questions/15809594/jquery-select2-plugin-how-to-get-only

How to use jQuery Select2 with AngularJS

南笙酒味 提交于 2019-12-19 19:40:54
问题 I am trying to use jQuery (2.2.1) Select2 (3.5.2) with Angularjs (1.5) but am having a difficult time grabbing the data from the select box. I have tried ui-select and I could retrieve data... but would often crash the browser when searching, was horribly slow and overall unstable (5000-10000 items). jQuery Select2 is fast and responsive, even with the large number of entries, but I cant seem to get the object when I select an option. <head> <script src="~/Scripts/angular.min.js"></script>

Focusing Input after Select2 close event fire

╄→гoц情女王★ 提交于 2019-12-19 12:23:30
问题 I read always trigger "change"-event for <select>, even if the select2-option clicked is already selected and as the problem was so close to my issue I asked my question there but no answer provided. My problem is that I have a select-box constructed by Select2 and a text input. What I want to achieve is after Select2 closed (no matter the value is changed or not) my text input become focus . So I did something logically fine as follow: $('#select').select2({placeholder: 'City'}); $('#select'

select2 search - match only words that start with search term

纵饮孤独 提交于 2019-12-19 05:23:54
问题 I migrated from chosen to select2 plugin because it works better for me, but its documentation is very poor when compared to chosen. Could anyone tell me what option(s) should be used to make select2 search function to filter words that just begin with search term (and don't contain it in the middle). Let's say select2 field has those options: banana, apple, pineapple. When user enters "app" (or apple), only apple should be returned (because it's the only word that starts with apple). Now, it

Select2 with multiple nested groups

风流意气都作罢 提交于 2019-12-18 16:49:24
问题 I'm having trouble using the Select2 with various groups, only the latter appears. <select name="txtConta" id="txtConta" data-placeholder="Selecione a conta"> <option value=""></option> <option value="S11892">2 - Gastos</option> <option value="S11893">2.1 - DESPESA OPERACIONAL FIXA</option> <option value="S11895">2.1.1 - PESSOAL</option> <option value="S11915">2.1.1.1 - GERENCIA/ADMINSTRATIVO</option> <option value="11916">2.1.1.1.1 - SALÁRIOS</option> <option value="11917">2.1.1.1.2 -

Clear select2 without triggering change event

北慕城南 提交于 2019-12-18 12:21:57
问题 I have a select2 input that I'm using and on 'change' I'm grabbing the values and performing an action. I'm trying to clear that select2 without triggering a change event. Is this possible? To clear the select2 I'm using the following code: $docInput.select2('data', null); This clears the input as desired, but also triggers a change event which runs through my other code. There must be a way to silence the trigger. Any ideas? 回答1: I believe all you need is: $docInput.select2('data', null,