jquery-select2

Select2 auto trigger event change

纵饮孤独 提交于 2019-12-05 04:08:46
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,selectorDestino) { id = selectorOrigen; alert(id); destino = "#"+selectorDestino; valor = $('#'+id).find

Select2 default options with ajax

时光毁灭记忆、已成空白 提交于 2019-12-05 03:43:49
I have next html structure <select class="change_item_dropdown_ajax form-control" id="item_id" name="item_id" onchange="updateData(this, this.value, 16)" > <optgroup label="System Data"> <option value="17">Test</option> <option selected="selected" value="18">System</option> </optgroup> </select> Javascript $(".change_item_dropdown_ajax").select2({ ajax: { url: "get_user_items", dataType: 'json', delay: 250, theme: "classic", data: function (params) { return { q: { name_contains: params.term } // search term }; }, processResults: function (data) { return { results: data }; }, cache: true },

jQuery Select2 Tag on Blur

蓝咒 提交于 2019-12-05 02:53:18
I'm using Select2 to create a Gmail-style e-mail addresses field in my application. It works great except for one case: when the user types in an e-mail address and doesn't put a space or comma after it, and doesn't hit enter or tab. For example, if they just type an e-mail address and then use the mouse to select the next field in the form, the e-mail address they typed goes away. I have an example jsfiddle here that illustrates the problem. Here's how I'm setting up select2 on my hidden input: $(function(){ $('input').select2({ tags: [], width: "300px", dropdownCss: {display: 'none'},

Angular UI Select2, why does ng-model get set as JSON string?

夙愿已清 提交于 2019-12-05 02:08:05
I'm using angular-ui's select2 for a fairly simple dropdown. It's backed by a static array of data sitting on my controller's scope. In my controller I have a function that gets called on ng-change of the dropdown so that I can perform some actions when the value changes. However, what I'm finding is that the ng-model's property gets set as a JSON string rather than an actual javascript object, which makes it impossible to use dot notation to grab properties off of that model. Here's the function that handles the value of the dropdown getting changed: $scope.roleTypeChanged = function() { /

Prevent select2 from autmatically focussing its search-input when dropdown is opened

≡放荡痞女 提交于 2019-12-05 00:58:25
I'm looking for a way to prevent select2's search-input being automatically focussed when the select2-dropdown is opened. I know this is select2's intended default behavior - and while this is fine for desktop clients, I need to prevent this behavior for the iPad where it triggers the iPads software keyboard, which is not what we want as a default. I've searched for an option to do so with no luck. http://jsfiddle.net/KwW5n/2/ reflects our setup - we're using a simple -element as a base for our select2-functionality: $('#source').select2(); This worked for me on select2 v4: // keep search

How to break a line in select2 dropdown?

这一生的挚爱 提交于 2019-12-04 23:53:46
I am using a select 2 dropdown and then showing some long sentences in its content. I want to add line breaks to the sentence at the right place but the drop down is auto adjusting. For example the content of the dropdown right now looks like this : The line looks like this right now select 2 installments of $100. (special offer.) I Need to add controlled line breaks so that it looks like this: select 2 installments of $100. (special offer.) I don't wan't to increase the width of dropdown or change the font size. My code is here at jsfiddle : <select multiple id="e1" style="width:300px">

Select2 - make it readonly (not disabled!) from js

二次信任 提交于 2019-12-04 23:42:23
How can I dynamically make a select2 combobox read-only? Here's what I've tried so far: $('...').attr({'readonly': 'readonly'}).trigger('change.select2'); $('...').attr({'readonly': 'readonly'}).trigger('change'); $('...').select2().enable(false); Cas Knook See: http://select2.github.io/select2/ I did it with: $("#modelname-fieldname").select2({disabled:readonly}); Where: modelname-fieldname is as in: $form -> field($modelname, "fieldname") -> widget(Select2::classname(), [ ... ]); readonly is true, false or a string readonly Optionally you can change the cursor when hovering over the select2

Open the drop down list permanently of select2

末鹿安然 提交于 2019-12-04 23:40:06
I'm using select2 for multiple value selection. I need to display the drop down list permanently. Right now when we select or click the input box of select2, the drop down list is displayed. I'd like to know if there is any way we can always show the list. From the select2 documentation, here : $("#select").select2({ closeOnSelect: false }); 来源: https://stackoverflow.com/questions/17107963/open-the-drop-down-list-permanently-of-select2

jquery select2 howto make dont close after select

我的未来我决定 提交于 2019-12-04 23:23:12
When using "Multi-Value Select Boxes" http://ivaynberg.github.io/select2/ slect box drop back after each selection. Is there the way not to do it, so user can select few of it without extra click to select box? Also interested in group options. In demo url above, "Pasific Time Zone", "Mountain Time Zone" not clickable. How to make it clickable and autoselect child items? Question 1: From the documentation I can see this option: closeOnSelect: false This option is set to true by default, meaning the select box closes on select. So, this is a simple call of the plugin: $('#mySelect').select2({

Select2 not using my templateResults or templateSelection options

99封情书 提交于 2019-12-04 23:14:51
I am trying to use the select2 ajax call with templates. I am getting the ajax in just fine but it is not using my template functions. the ajax data is: [ {"name":"First thing","otherData":"asdfg"}, {"name":"Second thing","otherData":"qqerr"}, {"name":"third thing","otherData":"yerty"}, {"name":"fourth thing","otherData":"hgjfgh"}, {"name":"fifth thing","otherData":"fhgkk"} ] the select2 code (which i took a lot from here ) is: FundSearch = { create: function (selector, theURL) { $(selector).select2({ ajax: { url: theURL, dataType: 'json', delay: 250, data: function (params) { console.log