select2

select2 : cannot read property query of null

亡梦爱人 提交于 2019-12-24 01:54:56
问题 I have create javascript like this $(document).on("select2:open", ".provider_suggestion", function() { $(this).select2({ minimumInputLength: 2, ajax: { url: "../include/suggestion/provider_name.php", dataType: 'json', delay: 250, data: function(params){ return { q: params.term }; }, processResults: function (data, page) { return { results: data }; }, cache: true } }); }); and create select html input like this <select id="c_providers" name="c_providers" class="provider_suggestion" style=

开发杂记

人走茶凉 提交于 2019-12-23 12:10:35
1. Ajax 请求 $.getrdsqlResult = function() { var nocoderd = $.ajax({ type: "POST", url: '<?php echo $this->ModuleUrl ?>/report/selectdisplay', async: false, cache: false, data: $("#testform").serializeArray(), beforeSend: function() { add_part_loading(11, true); }, success: function(msg){ if (msg.error > 0){ $('#enterSql').parent().addClass('has-error'); $('#enterSql').siblings().html(msg.msg); // $('#selectDisplay').css('display','none');tableResult $(".resultTab").hide(); $("#tableResult").html(""); $('#formCodeDiv').css('display','none'); return false; }else{ $('#enterSql').parent()

How to append jquery select2 values with initSelection

a 夏天 提交于 2019-12-20 02:52:38
问题 Here is my select2 multiple select with ajax. Initially i am setting some values in the initselection like this initSelection : function (element, callback) { var data = {id: 4, zipcode: "00602"}; callback(data); }; And then i am doing the ajax selection. But i can't able to sustain the old values. i.e., when i type the new selection, the old values are replaced instead of appending . Here is my entire code. var $select = $('#firstList'); $select.select2({ placeholder : "Enter Pincode",

Select right value for select when using select2 with jqGrid

空扰寡人 提交于 2019-12-19 11:34:41
问题 I'm using select2 with jqGrid. For "select" elemets I do folowing: {label:"Teacher",name:"teacher",index:"teacher",editable:true,edittype:"select", editoptions:{ dataUrl:"../ajax/selects/select_teachers.php", width:"400px", dataInit: function (elem) { $(elem).select2({ placeholder: "Choose teacher", allowClear: true, language:"ru" }); setTimeout(function() { $(".select2-container").width("300"); }, 0); }, }, But when open editForm select in in default mode. How to get select2 to select right

select2 is not working

你说的曾经没有我的故事 提交于 2019-12-14 03:29:49
问题 My select2 is not working. It just shows up with multiple selectbox <form action=""> <select class="js-example-basic-multiple" multiple="multiple"> <option value="AK">Alaska</option> <option value="HI">Hawaii</option> <option value="CA">California</option> <option value="NV">Nevada</option> <option value="OR">Oregon</option> <option value="WA">Washington</option> <option value="AZ">Arizona</option> <option value="CO">Colorado</option> <option value="ID">Idaho</option> <option value="MT"

Yii2: Kartik Select2: Initial Value from Model Attribute

随声附和 提交于 2019-12-13 07:25:12
问题 I have a Model who has a column (attribute) that stored a comma separated value of IDs. For Example, Movie has a column "Genre" that includes more than one genre, e.g.: 40,20,1,3 How can I use Select2 widget to show these values separated when 'multiple' => true And how can I save them back into comma-separated value as a string. I want a solution that will allow for quick flexibility. I know you can implode and explode the string but seems too much. Any help appreciated 回答1: If I remember

Select2 trigger(“change”) creates an infinite loop

不打扰是莪最后的温柔 提交于 2019-12-13 06:55:06
问题 Let say there are two select2 elements on the page, both using the 'onChange'. In order to programmatically set a value in one select2 element you use $('#id1').val('xyz').trigger('change'); If when you make a selection in one of these two elements you want to reset the other to the initial value, the onChange event is triggered by the value setting and the system enters an infinite loop. The same happens if you use $('#id1').val('xyz').trigger('change.select2') 回答1: To avoid inifinite loop

how to use select2 bootstrap

▼魔方 西西 提交于 2019-12-13 06:49:16
问题 im new at select2 im using bootsrap v3.3.6 how to plugin the select2 bootstrap? i already input <link href="css/select2.css" rel="stylesheet"> <link href="css/select2-bootstrap.css" rel="stylesheet"> <select id="position" style="width: 15%"> <option value=""></option> <option>One</option> <option>Two</option> <script src="js/select2.js"></script> $("#position").select2({ allowClear:true, placeholder: 'Position' }); but the output still like the default select2. not like bootstrap, please help

How to make a Select2 4.0 sortable?

被刻印的时光 ゝ 提交于 2019-12-13 01:27:06
问题 I had this problem with the new version 4.0, and wasn't able to find any answer, until I myself solved with a work around after some hours of work. 回答1: My workaround solution: First, make it sortable with jquery. $("#mySelect").parent().find("ul.select2-selection__rendered").sortable({ containment: 'parent', update: function() { orderSortedValues(); } }); The function orderSortedValues has the following idea: Change the order of the options of the original select input, and notifying select2

Fill two other fields of a formset depending on autocomplete selection

夙愿已清 提交于 2019-12-12 19:00:30
问题 I would like to fill two other fields automatically depending upon the selection someone makes in an autocomplete field, using django-autocomplete-light. However, my java script is not that good, so I don't really know where to start. Any help is very much appreciated. User submit their publicized papers. There is a "person" autocomplete field in a formset (its a many to many relation for authors and other people that worked towards the publication). If a user chooses a person, I want that