jquery-select2

Select2 multiple-select - programmatically deselect/unselect item

风格不统一 提交于 2019-12-04 21:06:42
问题 I have a select2 list and a set of external buttons. I wanted to click the external buttons and unselect corresponding items in the select2 list. I know I can do item selection from external value using the command $("#external_btn").click(function() { $("#select2").val("CA").trigger("change"); }); So when I click on the "external_btn" button, the "ca" item will be selected on the select2. But how I can do item unselection? Thanks. 回答1: There does not appear to be a built-in function to

Selenium IDE-Automating Select2 Search Box

只愿长相守 提交于 2019-12-04 20:06:26
问题 I am trying to automate the select2 search box in selenium IDE. I got it to open and also typed the search keyword I am searching for.However even though I have the code in place for showing results, it does not work. The problem is I guess the characters are getting typed too fast, so the results don't show up for the search box. I am sure I am going wrong somewhere, because I am new to Selenium IDE .So any help is appreciated mouseDown css=.select2-choice > div > b type css=input.select2

Select2 load data with Ajax from file

流过昼夜 提交于 2019-12-04 18:55:13
问题 I have a script called listofValues.php , which queries a database and returns JSON format values. What I need is to pass these values to the select2 data member. I need it to load once. I don't need to pass values from select2 input (term) to my listofValues.php as described in this example $('#select2div').select2({ //data:[], ajax: { dataType: "json", url: "listofvalues.php", success: function (data) { } } Can you help me with this? 回答1: Simple Example It would be useful to know the format

select2 plugin and jquery ui modal dialogs

夙愿已清 提交于 2019-12-04 18:30:22
问题 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

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

南笙酒味 提交于 2019-12-04 17:36:33
问题 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

How to add HTML content at select2 dropdown box

房东的猫 提交于 2019-12-04 17:35:43
问题 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'},

Select2 add image icon to option dynamically

三世轮回 提交于 2019-12-04 16:15:46
问题 This is what select2.github.io gives you: function addIcons(opt) { if (!opt.id) { return opt.text; } var $opt = $( '<span><img src="/images/flags/' + opt.element.value.toLowerCase() + '.png" class="img-flag" /> ' + opt.text + '</span>' ); return $opt; } I'd like to add a data-image attribute to my options: <option value="flag" data-image="/images/flags/flag.png">Country 1</option> and log it in the function: function addIcons(opt) { if (!opt.id) { return opt.text; } var optimage = opt.attr(

Dynamic select2 not firing change event

我的梦境 提交于 2019-12-04 15:28:41
问题 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

How does a select2 widget gets populated with AJAX?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 15:19:38
When I enter a few characters in my widget, I get results like these from AJAX: [{"id":550,"campName":"IB Resi Showtime Rebate Website"},{"id":60,"campName":"OB ACGBK EB"}] However, I'm missing the part on how to populate the widget with those results. Here is the code I use for the widget: $this->widget ( 'ext.ESelect2-master.ESelect2', [ 'selector'=>'#campaigns', 'options'=> [ 'tags'=>$tags, 'allowClear'=>true, 'minimumInputLength' => 2, 'width'=>'300px', 'multiple'=>true, 'placeholder'=>'Campaigns', 'ajax'=> [ 'url'=>Yii::app()->createUrl('CoxReports/autoCompleteCampaigns'), 'dataType'=>

django-autocomplete-light - how to return a different field then a models primary key?

随声附和 提交于 2019-12-04 14:17:44
I am using django-autocomplete-light in a form for a model I want to use autocomplete on one of its field. the field is not a foreignkey or something, but just a integer field and for autocomplete I would actually like to use the same model then the form I am filling. The query set from autocomplete however returns the ID and I want to fill the field "projektnummer". Any clue how I can setup autocomplete so that it returns not the primary key of the model but some other field? also it seems that I get a wired failure from crispy forms when I use the autocomplete-widget on the integer field.