jquery-select2-4

How to change the css of color of select2 tags?

╄→尐↘猪︶ㄣ 提交于 2019-11-29 11:59:40
问题 I just started using project for showing multiple tags from a select box and it works great, thanks for the library. I just need to modify the color or css of the tags shown in multi-value select-boxes. Right now the color of the tag is shown as grey and I would like to change that to some other color according to the type of the tag. Or at least is there a way to change the default color? Also is it possible to change the css class of tags? There is an option such as formatResultCssClass but

Select 2 version 4.0 allow user to enter free text

守給你的承諾、 提交于 2019-11-29 03:46:36
I am using the latest version of Select2: Select2 4.0 . I would like to allow users to enter free text. In other words if a user cannot find a option in the drop down (data returned by ajax), I want them to be able to 'select' whatever text they have typed in. This is my markup: <select class="required form-control" id="businessName" data-placeholder="Choose An Name" > </select> And this is the JavaScript that I am using to initialize Select2: $("#businessName").select2({ ajax: { url: "/register/namelookup", dataType: 'json', delay: 250, type: 'post', data: function (params) { return {

select2 load data using ajax cannot select any option

大憨熊 提交于 2019-11-29 01:29:48
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(response){ return '<div>'+response.Name+'</div>'; }, templateSelection: function(response){ return

jquery select2: error in getting data from php-mysql

泄露秘密 提交于 2019-11-28 11:45:16
I am testing select2 plugin in my local machine. But for some reason. it is not collecting the data from database. I tried multiple times but not able to find the issue. Below are the code . <div class="form-group"> <div class="col-sm-6"> <input type="hidden" id="tags" style="width: 300px"/> </div> </div> <script type="text/javascript"> var lastResults = []; $("#tags").select2({ multiple: true, placeholder: "Please enter tags", tokenSeparators: [","], initSelection : function (element, callback) { var data = []; $(element.val().split(",")).each(function () { data.push({id: this, text: this});

Aurelia trying to load HTML from Select2?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 08:15:34
问题 So I'm trying to use Select2 within my Aurelia application. I installed Select2 using jspm install select2 , and within my app.html file I require Select2 using <require from="select2/js/select2.min.js"></require> . The browser loads the minified JS file fine, but for some reason it also tries to load http://localhost:3003/jspm_packages/github/select2/select2@4.0.0/js/select2.min .html . Why is Aurelia trying to load the HTML counterpart of the same JS file that I specified in my <require>

Chaining multiple Select2 together

若如初见. 提交于 2019-11-27 21:53:02
问题 Trying to make two chained auto populating select fields using select2 plugin The first select contains countries names(static select) and the second shows the states of the country selected from the first select my code is <select id="country" name="country" size="1" class=" form-control"> <option></option> <option value="1">USA</option> <option value="2">Untied Kingdom</option> <option value="3">France</option> etc........ </select> <select id="states" name="states" size="1" class="form

Select 2 version 4.0 allow user to enter free text

旧时模样 提交于 2019-11-27 17:47:36
问题 I am using the latest version of Select2: Select2 4.0. I would like to allow users to enter free text. In other words if a user cannot find a option in the drop down (data returned by ajax), I want them to be able to 'select' whatever text they have typed in. This is my markup: <select class="required form-control" id="businessName" data-placeholder="Choose An Name" > </select> And this is the JavaScript that I am using to initialize Select2: $("#businessName").select2({ ajax: { url: "

How to programmatically inject search queries into Select2 v4?

人盡茶涼 提交于 2019-11-27 15:43:19
问题 I've built a web-app using a Select2 search box, which connects to our backend via AJAX. The search box passes the query (say "APPLES") to the backend, which then updates the page. How do I programmatically inject search queries into the search box? I need to pass in the "val" so that select2 calls the backend via AJAX and updates the page. I'm sure this is obvious, but I couldn't find it in the documentation. For example, instead of forcing a user to type "APPLES" into the search box, I

How to enable infinite scrolling in select2 4.0 without ajax

坚强是说给别人听的谎言 提交于 2019-11-27 15:16:22
问题 I am using select2 with custom data adapter. All of the data provided to select2 is generated locally in web page (so no need to use ajax). As query method can generate a lot of results (about 5k) opening select box is quite slow. As a remedy, I wanted to use infinite scroll. Documentation for custom data adapter says that query method should receive page parameter together with term : @param params.page The specific page that should be loaded. This is typically provided when working with

Select2 4.0 - Push new entry after creation

大城市里の小女人 提交于 2019-11-27 09:07:39
I have been using Select2 4.0.0-rc.1 for a couple of weeks (using the ajax adapter) and I am trying to find a way to "push" data after it has been initialized. Within the dropdown list, I have the choice to select an entry in the list (using ajax ) add a free entry (using createTag ) add a new entry If I select "add a new entry", I can fill out a form, and once saved, the new data must be shown as a selected entry. If I push data using select2_existing.select2( { data: data } ).val( 4 ); it works, but ajax call does not work anymore. I have then to destroy select2 re-create it Which will then