select2

Select2() is not a function

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So i have downloaded select2 i have "installed it" by putting it into my folder and then loaded it on my site when i check the console (where i can see all of the scripts being loaded) i can see the file select2.js I went to their documentation and copied it and added $("#e9").select2(); However when i load the page i get the following error: TypeError: $(...).select2 is not a function $("#e9").select2(); Have anyone else experianced anything like this? Additional information here is my script: 回答1: I was having this problem when I started

“query function not defined for Select2 undefined error”

匿名 (未验证) 提交于 2019-12-03 02:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Trying to use Select2 and getting this error on multiple item input/text field: "query function not defined for Select2 undefined error" 回答1: Covered in this google group thread The problem was because of the extra div that was being added by the select2. Select2 had added new div with class "select2-container form-select" to wrap the select created. So the next time i loaded the function, the error was being thrown as select2 was being attached to the div element. I changed my selector... Prefix select2 css identifier with specific tag name

Tagging with AJAX in select2

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am doing tagging with select2 I have these requirements with select2: I need to search some tags using select2 ajax Also I need to use "tags" in select2 which Allows values that are not in the list(Ajax result). Both the scenarios work independently. But joined together aJax values are only populated. If we type any other values not in the list then it says "no matches found" My scenario If user type any new value which is not in the list, allow them to make up their own tag. Any way to make this work? 回答1: Select2 has the function

Select2: How to prevent tags sorting

匿名 (未验证) 提交于 2019-12-03 01:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When user selects many items (tags), they are automatically sorted alphabetically. How to prevent automatic sort and keep user's order using Select2 4.0? Update: The mentioned "possible dublicate question" is for the older version of Select2 v3... I ask about version 4... It differs form older ones and mentioned answers dosn't solve the problem. 回答1: I've found a solution that works with Select2 v4. It changes the order of items - item selected by user are moved to the end. $("select").select2(); $("select").on("select2:select", function

How to set selected value of jquery select2?

匿名 (未验证) 提交于 2019-12-03 01:17:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This belong to codes prior to select2 version 4 I have a simple code of select2 that get data from ajax $("#programid").select2({ placeholder: "Select a Program", allowClear: true, minimumInputLength: 3, ajax: { url: "ajax.php", dataType: 'json', quietMillis: 200, data: function (term, page) { return { term: term, //search term flag: 'selectprogram', page: page // page number }; }, results: function (data) { return {results: data}; } }, dropdownCssClass: "bigdrop", escapeMarkup: function (m) { return m; } }); This code is working, however, I

Blur Select2 input after close

匿名 (未验证) 提交于 2019-12-03 01:12:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want the select2 element to lose the focus when the select2-close event is triggered, what I have tried so far was: .on("select2-close", function (e) { var $focused = $(':focus'); $focused.blur(); }); and some variations to get focused element like document.activeElement , $(e.target) non f these worked. JSFiddle 回答1: You need to remove the .select2-container-active class from the containing divider: .on("select2-close", function () { setTimeout(function() { $('.select2-container-active').removeClass('select2-container-active'); $(':focus'

Trigger an action after selection select2

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using select2 library for my search. is there any way to trigger an action after selecting a search result? e.g. open a popup, or a simple js alert. $("#e6").select2({ placeholder: "Enter an item id please", minimumInputLength: 1, ajax: { // instead of writing the function to execute the request we use Select2's convenient helper url: "index.php?r=sia/searchresults", dataType: 'jsonp', quietMillis: 3000, data: function (term, page) { return { q: term, // search term page_limit: 10, id: 10 }; }, results: function (data, page) { // parse

Select2 ajax not showing results

匿名 (未验证) 提交于 2019-12-03 00:55:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using select2 and ajax to query my database for terms under a certain taxonomy, but when I search the search boxes just hangs on "searching" without retrieving any results. This is my html <select multiple="" name="regions1[]" id="regions1" class="job-manager-multiselect select2-hidden-accessible" required="" tabindex="-1" aria-hidden="true"></select> My jquery: <script> jQuery(function($) { $(document).ready(function() { $( "#regions1" ).select2({ ajax: { url: "/ajax/connect.php", dataType: 'json', delay: 250, data: function (params) {

Select2 acts very different with Uncaught query function not defined for Select2 &lt;select2-id&gt;

匿名 (未验证) 提交于 2019-12-03 00:51:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I load values for select2 like the following way. Declare the Type var AdjustmentType = Backbone.Model.extend({ url : Hexgen.getContextPath("/referencedata/adjustmenttype") }); create instance for the Type var adjustmentTypes = new AdjustmentType(); load the values to select2 box adjustmentTypes.fetch({ success : function() { for(var count in adjustmentTypes.attributes) { $("#adjustment-type").append("<option>" + adjustmentTypes.attributes[count] + "</option>"); } } }); $("#adjustment-type").select2({ placeholder: "Select Adjustment Type",

Open the drop down list permanently of select2

匿名 (未验证) 提交于 2019-12-03 00:46:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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. 回答1: From the select2 documentation, here : $("#select").select2({ closeOnSelect: false }); 文章来源: Open the drop down list permanently of select2