jquery-select2

set json data from ajax and make it serarchable in select2 jQuery

走远了吗. 提交于 2019-12-18 09:52:54
问题 I had two drop down input fields, both are implementing Select2 Jquery. Here i set the data as static for first drop down . its works fine . As per selection of value in first drop down, next drop down will filled by another set of json data by ajax. I need to second drop down should be searchable with only once loaded the ajax data. but i am not get correctly. i not able to make it workable. i used the following scripts function format(item) { return item.name; } var data=[{"id":"1995","name

how to add Button to a select2 dropdown on a dynamic table

你离开我真会死。 提交于 2019-12-18 08:52:14
问题 Good day! Im doing a Dynamic table which you can add/remove row, and Im using select2 to search Items on the database via ajax and its working well at the moment, then I want to add another button ("add new item") to my select2's input box. It was also working but when I add another row, the previous rows will have 2 (add new item) buttons on it, and when I add another row something weird is happening on my input box then. without adding new rows after adding new rows Here is my code: $

select2 multiple versions on same page/site

≡放荡痞女 提交于 2019-12-18 07:16:32
问题 Afternoon, On a website I already updated lots of elements that used select2 v. 3.5.2 to the new v. 4.0 (and some of those elements are on the header of the website that is present on ALL pages) Unfortunately on some pages of the website the X-editable jquery plugin is used, and that plugin doesn't play well with v 4.0 of select2 (please read: does not play at all) My question is: Can I use both versions of select2 on some pages? And if so, how? Since $(...).select2(); is blind to which

Blur Select2 input after close

匆匆过客 提交于 2019-12-18 06:23:16
问题 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')

select2 change background color

南笙酒味 提交于 2019-12-18 05:44:12
问题 I am trying to use select2 on a webpage I am creating. However the combobox background seems to be transparent but I need to change it to another color. I tried modifying the select2.css file but nothing seems to work. Any Ideas ? 回答1: If you are trying to target the combo box wrapper use .select2-search { background-color: #00f; } If you are trying to target the input use .select2-search input { background-color: #00f; } And if you are trying to target the results wrapper use .select2

select2 change background color

 ̄綄美尐妖づ 提交于 2019-12-18 05:43:59
问题 I am trying to use select2 on a webpage I am creating. However the combobox background seems to be transparent but I need to change it to another color. I tried modifying the select2.css file but nothing seems to work. Any Ideas ? 回答1: If you are trying to target the combo box wrapper use .select2-search { background-color: #00f; } If you are trying to target the input use .select2-search input { background-color: #00f; } And if you are trying to target the results wrapper use .select2

Select2 Ajax not filtering results based on query

北战南征 提交于 2019-12-18 04:41:12
问题 I am new to Select2 and am having trouble integrating AJAX. When I search, the results aren't being filtered based on the query. Here's how it looks: http://i.imgur.com/dAPSSDH.png - The right characters are underlined in the results, but nothing is filtered out. In my non-ajax Select2 and in the examples I've seen, the filtering seems to happen somewhat automatically, so I am hesitant to write a custom filter as there is probably a better one built in already. Here's my code: <script> $("

Select2 Ajax not filtering results based on query

↘锁芯ラ 提交于 2019-12-18 04:41:05
问题 I am new to Select2 and am having trouble integrating AJAX. When I search, the results aren't being filtered based on the query. Here's how it looks: http://i.imgur.com/dAPSSDH.png - The right characters are underlined in the results, but nothing is filtered out. In my non-ajax Select2 and in the examples I've seen, the filtering seems to happen somewhat automatically, so I am hesitant to write a custom filter as there is probably a better one built in already. Here's my code: <script> $("

select2 load data using ajax cannot select any option

余生颓废 提交于 2019-12-18 03:10:08
问题 I have the following code (javascript): $('#cbxConnections').select2({ minimumInputLength: 0, multiple: false, allowClear: true, placeholder:{ text:"@Diccionario.Connections", id:" @Diccionario.Connections" }, ajax:{ url:'@Url.Action("GetActiveConnections","Admin")', dataType: 'json', type:'post', data:function(params){ return { q: params.term }; }, processResults: function(data,page){ return { results: data }; } }, escapeMarkup: function (markup) { return markup; }, templateResult: function

jquery select2 - not working

感情迁移 提交于 2019-12-18 03:04:42
问题 I am using select2 plugin(ivaynberg.github.io/select2). I am trying to display a dropdown(select). It is getting all the items in data.php as options. However select2 is meant to be autocomplete plugin and should search for the search term a client input, and display the matching results only. At the moment it is displaying all the items and not getting the search results. Sorry for my language data.php is echoing out this: [{ "id": "1", "text": "item1", "exercise": "blah text" }, { "id": "2"