ui-select2

Protractor how to test select2

独自空忆成欢 提交于 2019-11-30 23:22:35
I have a select2 drop-down where you need to first enter 2 characters and then select your item. I am unable to test this with Protractor. var select2 = element(by.css('div#s2id_person')); select2.click(); select2.sendKeys('ip'); select2.sendKeys(protractor.Key.ENTER); The following gets an error about being unable to focus the element when you try to sendKeys. The following snippet successfully activates and selects the first option in a select2 widget, it allows for loading options over a network. There are several issues with the 'select2' widget - in regard to protractor E2E testing -

How to get Selected Text from select2 when using <input>

本小妞迷上赌 提交于 2019-11-28 17:09:21
I am using the select2 control, loading data via ajax. This requires the use of the <input type=hidden..> tag. Now, I want to retrieve the selected text. (The value property in the data-bind expression sotres the id only) I have tried $(".select2-chosen").text() , but this breaks when I have multiple select2 controls on the page. As of Select2 4.x, it always returns an array, even for non-multi select lists. var data = $('your-original-element').select2('data') alert(data[0].text); alert(data[0].id); For Select2 3.x and lower Single select: var data = $('your-original-element').select2('data')

How to get Selected Text from select2 when using <input>

允我心安 提交于 2019-11-27 10:14:14
问题 I am using the select2 control, loading data via ajax. This requires the use of the <input type=hidden..> tag. Now, I want to retrieve the selected text. (The value property in the data-bind expression sotres the id only) I have tried $(".select2-chosen").text() , but this breaks when I have multiple select2 controls on the page. 回答1: As of Select2 4.x, it always returns an array, even for non-multi select lists. var data = $('your-original-element').select2('data') alert(data[0].text); alert

How do I change selected value of select2 dropdown with JqGrid?

倖福魔咒の 提交于 2019-11-26 19:29:05
I'm using Oleg's select2 demo , but I am wondering whether it would be possible to change the currently selected value in the dropdown menu. For example, if the four values loaded were: "Any", "Fruit", "Vegetable", "Meat" and the dropdown list defaulted to "Any" , how would I be able to change that to "Fruit" in the JqGrid event loadComplete ? Is this possible? For select2 version >= 4.0.0 The other solutions might not work, however the following examples should work. Solution 1: Causes all attached change events to trigger, including select2 $('select').val('1').trigger('change'); Solution 2:

How do I change selected value of select2 dropdown with JqGrid?

放肆的年华 提交于 2019-11-26 06:57:49
问题 I\'m using Oleg\'s select2 demo, but I am wondering whether it would be possible to change the currently selected value in the dropdown menu. For example, if the four values loaded were: \"Any\", \"Fruit\", \"Vegetable\", \"Meat\" and the dropdown list defaulted to \"Any\" , how would I be able to change that to \"Fruit\" in the JqGrid event loadComplete ? Is this possible? 回答1: For select2 version >= 4.0.0 The other solutions might not work, however the following examples should work.