jquery-select2

How to use select2 with Meteor?

三世轮回 提交于 2020-01-03 13:01:00
问题 can someone explain to me how select2 works with Meteor? I am using zimme:select2-boostrap3-css and I have no clue on how to use it. I checked both the original select2 github page and the one from the package. The first one explains how to use it without Meteor. Do I just add the jQuery code to one of my *.js-files in order to get it to work? In HTML: <select class="input" id="clientName" name="clientName"> {{#each getClients}} <option value="{{clientName}}" data-id={{_id}}>{{clientName}}<

jQuery select2 AJAX not working

∥☆過路亽.° 提交于 2020-01-03 07:49:22
问题 I'm using the jQuery select2 plugin and trying to get the AJAX to work with my ext data which is obviously not working and I'm just wondering if someone can point out what I'm doing wrong or missing something? NOTE This is only for select v3.5.2 my js: $('#cliselect').select2({ ajax: { dataType: "json", url: "clientprojectpopulate.php", results: function (data) { return {results: data}; } } }); html: <select id="cliselect" name="cliselect" style="width: 100%;" /></select> my JSON returns

Placeholder not working in select2

本秂侑毒 提交于 2020-01-03 07:29:09
问题 I am working Select2 Select-box. Problem Placeholder is not showing in select2 . It is always show the first option selected in the select2 . It's automatically select first option i want to show the placeholder instead of it. My Code: Script: <script type="text/javascript"> $(document).ready(function () { var data = $('#test_skill').select2({ placeholder: "Please select an skill", allowClear: true }); }); // I have also tried this: This is also not working $('#test_skill').select2({

Set pipe as the delimiter for Select2

狂风中的少年 提交于 2020-01-03 04:45:22
问题 I have one multiple select dropdown, and I want to set pipe ( | ) as the delimiter. For example, when a user selects multiple options (like Option1, Option2 and Option3) then it should separate (delimit) the values like this: Option1|Option2|Option3 Below is my code: $("#granttype").select2({ allowClear: true, tags: true, tokenSeparators: ['|'] }); I wrote this in the $document.ready() function. 回答1: You have to use option tokenSeparators $("#selectbox").select2({ tags: true, tokenSeparators:

Select2.js: why is id the same as text on change for removed?

可紊 提交于 2020-01-02 09:12:17
问题 JSfiddle: http://jsfiddle.net/cjVSj/ I have a simple select2 with the range of possible tags set by the tags option and the preloaded tags set by values in the input field in the html. When the on change event fires on the select2, the removed item seems to lose its id, reporting instead its text value. To see the problem, adding a tag (e.g. west) correctly reports the added.id, but removing the existing east tags reports id = east, not 1356. Any insight into how to gain access to the id of a

Open the drop down list permanently of select2

二次信任 提交于 2020-01-02 00:48:13
问题 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 }); 来源: https://stackoverflow.com/questions/17107963/open-the-drop-down-list-permanently-of-select2

Use dynamic AJAX URL for Vue Select2 wrapper component

假装没事ソ 提交于 2020-01-01 19:20:53
问题 I modified the Wrapper Component Example from the VueJS documentation to include the AJAX datasource option. Here is my code. However, I would like to set the ajax url property of my select2 component dynamically preferably like this, <select2 :options="options" v-model="selected" url="dynamic-url-here"> <option disabled value="0">Select one</option> </select2> How would I do this? 回答1: Add the property to the Component's props : Vue.component('select2', { props: ['options', 'value', 'url'],

Select2 jquery - How to get text in selectbox

自闭症网瘾萝莉.ら 提交于 2020-01-01 12:14:11
问题 I have input text like <input type="hidden" name="xa" id="xa" data-placeholder=".." style ="width: 360px;"/> and i using select2 $("#xa").select2({...}); now, i want to get text when i press 'get text' $("#gettext").click(function () { alert($('#xa').val()); // or $('#xa').select2("val"); }); But it get the id of text. It's not text. How can i do it. thanks 回答1: Select2 creates a data- attribute for internal purpose, were it stores some necessary information like id , selected value of

Set data in Select2 after insert with AJAX

孤街醉人 提交于 2020-01-01 02:35:14
问题 i'm using the Select2 with AJAX (the code below): $(".select2-ajax").select2({ placeholder: "Search user", minimumInputLength: 1, ajax: { url: $('#url-search-client').val(), dataType: 'json', type: 'post', data: function (term, page) { return { filter: term }; }, results: function (data, page) { return {results: data}; } }, width : '50%', formatInputTooShort: function () {return 'Informe mais caracteres'; }, formatResult: formatResultSelectAjax, // omitted for brevity, see the source of this

django/ajax CSRF token missing

半城伤御伤魂 提交于 2019-12-31 07:08:41
问题 I have the following ajax function which is giving me a cross site forgery request token error once I get past the minimumlengthinput of 3 with the select2 control. Knowing this I attempted to add { csrfmiddlewaretoken: '{{ csrf_token }}' }, to my data:. After adding the csrfmiddlewaretoken I'm still getting the CSRF token missing or incorrect error. I believe it has something to do with the my function for the searchFilter and searchPage follows. What is the proper way to do this? // using