jquery-select2

Auto tokenize last item in pasted string using select2

﹥>﹥吖頭↗ 提交于 2019-12-03 17:22:45
I am using jQuery Select2 to create an input that allows auto tokenization. I've initialized the select2 input with the following options: { tags: [''], tokenSeparators = [',', ' '] } Very basic stuff. When I type a string of text into the input, followed by a comma or space, the preceding string is tokenized, exactly as I would expect. However, I need to support pasting of text into the input. This is where things fall apart. If I paste '1,2,3,4' into the input, I get separate tokens for 1, 2, and 3, but 4 is not tokenized. Instead, it remains as the value of the input.select2-input and when

select2 ajax won't display json data returned

和自甴很熟 提交于 2019-12-03 16:34:56
Here is what the json string looks like that gets returned from my coldfusion page: [{"client":"Asante","id":12},{"client":"City of Lancaster","id":14},{"client":"Massey Energy","id":35},{"client":"Northeast Utilities","id":68},{"client":"Washtenaw","id":50}] . Firebug claims everything is working perfectly but none of the data shows up in the select2 plugin. Does anyone know what the problem might be? Should it be returning column names or something? select2 call: $(".select").select2({ allowClear: true, blurOnChange: true, openOnEnter: false, ajax: { url: "/surveymanagement/admin/client.cfc"

How to handle ordered many-to-many relationship (association proxy) in Flask-Admin form?

↘锁芯ラ 提交于 2019-12-03 16:22:22
I have a many-to-many relationship between declarative models Page and Survey , which is mediated by association proxies because the order in which pages appear in a survey is important, so the cross-linking table has an additional field. from flask.ext.sqlalchemy import SQLAlchemy from sqlalchemy.ext.associationproxy import association_proxy db = SQLAlchemy() class Page (db.Model): id = db.Column(db.Integer, primary_key = True) surveys = association_proxy('page_surveys', 'survey') class Survey (db.Model): id = db.Column(db.Integer, primary_key = True) pages = association_proxy('survey_pages',

javascript select2 allowed tags

百般思念 提交于 2019-12-03 15:35:40
问题 I need to allow users select ONLY allowed tags in select. Currently I have that: $("input#id_txtcolor").select2({tags:["red", "green", "blue"]}); Can you help me please with that? 回答1: as of 3.3 you can specify your own createSearchChoice when using tags that will always return null, thus preventing the default choice from being created. $().select2({ createSearchChoice: function() { return null; }, tags:... }); 回答2: Sometimes we developer don't use our 7th sense that is common sense also

select2 plugin works fine when not inside a jquery modal dialog

为君一笑 提交于 2019-12-03 15:20:29
问题 I am using select2 plugin inside a jquery dialog but in does not work. When dropping down, the focus moves to the input control but immediately get out from it,not allowing me to type anything. This is the HTML: <div id="asignar_servicio" title="Asignar servicios a usuarios"> <input type="hidden" class="bigdrop" id="a_per_id" /> </div> And this is the javascript code: $( "#asignar_servicio" ).dialog({ autoOpen: false, height: 500, width: 450, modal: true, buttons: { "Cancelar": function () {

Select2 limit number of tags

前提是你 提交于 2019-12-03 14:30:22
问题 Is there a way to limit the number of tags a user can add to an input field using Select2? I have: $('#tags').select2({ containerCssClass: 'supplierTags', placeholder: "Usual suppliers...", minimumInputLength: 2, multiple: true, tokenSeparators: [",", " "], placeholder: 'Usual suppliers...', createSearchChoice: function(term, data) { if ($(data).filter(function() { return this.name.localeCompare(term) === 0; }).length === 0) { return {id: 0, name: term}; } }, id: function(e) { return e.id + "

Select2: how to set data after init?

与世无争的帅哥 提交于 2019-12-03 14:28:04
问题 I need to set an array of data after initializing select2. So I want to make something like this: var select = $('#select').select2({}); select.data([ {id: 1, text: 'value1'}, {id: 1, text: 'value1'} ]); But I get the following error: Option 'data' is not allowed for Select2 when attached to a element.; My HTML: <select id="select" class="chzn-select"></select> What should I use instead of a select element? I need to set the source of items for search 回答1: In onload: $.each(data, function

Selenium IDE-Automating Select2 Search Box

筅森魡賤 提交于 2019-12-03 14:07:53
I am trying to automate the select2 search box in selenium IDE. I got it to open and also typed the search keyword I am searching for.However even though I have the code in place for showing results, it does not work. The problem is I guess the characters are getting typed too fast, so the results don't show up for the search box. I am sure I am going wrong somewhere, because I am new to Selenium IDE .So any help is appreciated mouseDown css=.select2-choice > div > b type css=input.select2-input.select2-focused Chris waitForVisible css=.select2-results mouseUp css=.select2-result-label

Select2 multiple-select - programmatically deselect/unselect item

给你一囗甜甜゛ 提交于 2019-12-03 14:00:21
I have a select2 list and a set of external buttons. I wanted to click the external buttons and unselect corresponding items in the select2 list. I know I can do item selection from external value using the command $("#external_btn").click(function() { $("#select2").val("CA").trigger("change"); }); So when I click on the "external_btn" button, the "ca" item will be selected on the select2. But how I can do item unselection? Thanks. There does not appear to be a built-in function to programmatically deselect/unselect an option from a multiple-select Select2 control. (See this discussion .) But

Select2 load data with Ajax from file

不羁岁月 提交于 2019-12-03 13:22:19
I have a script called listofValues.php , which queries a database and returns JSON format values. What I need is to pass these values to the select2 data member. I need it to load once. I don't need to pass values from select2 input (term) to my listofValues.php as described in this example $('#select2div').select2({ //data:[], ajax: { dataType: "json", url: "listofvalues.php", success: function (data) { } } Can you help me with this? Simple Example It would be useful to know the format of the object you're getting back from listofvalues.php , but let's just assume, for the sake of simplicity