jquery-select2

Select2 - Ajax search - remember last results

做~自己de王妃 提交于 2019-11-30 19:36:12
I am using Select2 3.5.1. With this plugin I can successfully load remote data. However I am here today to ask a question to improve this search. Here is the step-by-step to understand what I would like to do: Setup a Select2 with remote data loading (using ajax). Click on the Select2 input and search for something. The loading will appear and after some seconds you will see a list of results. Click on one of the results listed - the box of results will then disappear. If you click again on the search box, the list will be empty and you will need to type some new text again to have a list of

How do I make select2 to work with Angular 7

坚强是说给别人听的谎言 提交于 2019-11-30 17:59:35
问题 Am trying to implement Select 2 into my Angular 7 project. I followed all the procedures to implement from github. But still its not working. It works when i present some static data into it. Its not populating the data from the webserver. Please share your ideas. Below is my code Html Code: <select2 [options]="areas" [settings]="{ width: '100%' }"></select2> <div *ngFor="let ar of areas"> <p>{{ar.Area_Name}}</p> </div> Component Code: import { Component } from '@angular/core'; import {

An event is interfering with Select2 plugin's ajax-retrieved results

久未见 提交于 2019-11-30 17:53:15
I'm using Igor Vaynberg's Select2 jQuery plugin with the Infinite Scroll with Remote Data option to make an autocomplete search box for my website. The AJAX is working great and the results are showing up, but they are unselectable -- the change event is never fired and when you click on a result, nothing happens. There are also no errors showing up in the Chrome console, so I think it's not a syntax error, rather the plugin is mistaking it for a disabled select box. EDIT: having tried a separate on-click event for the result list which never got fired either, I'm now pretty sure there's

Jquery bootstrap select2 plugin issue with validate plugin

空扰寡人 提交于 2019-11-30 17:04:05
In my bootstrap project I'm trying to use the plugin select2 but I realized that if you use this plugin are no longer able to validate select fields in my form with validate plugin. I would avoid using the commercial plugin bootstrap validator.. <div class="container"> <div class="row"> <form id="test_form" action="?"> <div class="col-md-3"> <div class="form-group"> <label for="name">Foo</label> <select class="form-control" id="foo" name="foo"> <option value=""></option> <option value="1">1</option> <option value="2">2</option> </select> </div> </div> <div class="col-md-3"> <div class="form

Select2 drop-down for countries, with flags

我只是一个虾纸丫 提交于 2019-11-30 14:09:41
问题 Does somebody have an easy to use example of a country drop-down, with country flags, for Select2 ? I am about to implement one based on this suggestion, but I would prefer to avoid reinventing the wheel. 回答1: I was working on a similar problem and here is how I solve it. (function($) { $(function() { var isoCountries = [ { id: 'AF', text: 'Afghanistan'}, ... ]; //Assuming you have a select element with name country // e.g. <select name="name"></select> $("[name='country']").select2({

Select2 not working inside bootstrap modal

一曲冷凌霜 提交于 2019-11-30 13:52:48
I am trying to use select2 inside bootstrap modal but it is not getting the focus automatically as well as down and up arrows are not working for the populated list. The same select2 works when I put it outside the modal popup. When I searched, I found many are facing this same problem and found this post Select2 doesn't work when embedded in a bootstrap modal I implemented both the solutions from it Removed tabindex from modal popup. Commented code of enforceFocus function in modal.js file. But it is still not working! Any idea what I could still be missing? Edit1 It works on firefox when

Programmatically set the value of a Select2 ajax

百般思念 提交于 2019-11-30 12:31:55
问题 I have a Select2 auto-complete input (built via SonataAdmin), but cannot for the life of me figure out how to programmatically set it to a known key/value pair. There's a JS Fiddle here that shows roughly what I have. What I want to know is what function I can attach to the button so that the Select2 field shows the text "NEW VALUE" to the user, and the Select2 field will submit a value of "1" when the form is sent to the server I have tried all sorts of combinations of jQuery and Select2

Select2 Event for creating a new tag

匆匆过客 提交于 2019-11-30 11:32:20
I'm using the jQuery Select2 (v4) plugin for a tag selector. I want to listen for when a new tag is created in the select element and fire an ajax request to store the new tag. I discovered there is the createTag event but this seems to fire every time a letter is entered into the select2 element. As shown in my fiddle: http://jsfiddle.net/3qkgagwk/1/ Is there a similar event that only fires when the new tag has finished being entered? I.e. it's enclosed by a grey box enclosing it. I can't find any native method unfortunately. But if you're interested in simple "workarounds", maybe this get

Override Minimum length string of Select2

你。 提交于 2019-11-30 11:06:42
Select2 Jquery Plugin I was having hard time how to override the default message for minimum length input in jquery Select2. by default the plugin gives the following message. Default Text Please enter 1 more characters My requirement was to show, the following text Required Text Enter 1 Character please share the solution. Thanks. The accepted answer does not work for Select2 v4. Expanding on the comment by @IsaacKleinman, the way to override the default messages for an individual Select2 instance is through the language property: var opts = { language: { inputTooShort: function(args) { //

set the width of select2 input (through Angular-ui directive)

↘锁芯ラ 提交于 2019-11-30 10:13:44
问题 I have problem making this plunkr (select2 + angulat-ui) work. http://plnkr.co/edit/NkdWUO?p=preview In local setup, I get the select2 work, but I cannot set the width as described in the docs. It is too narrow to be used. Thank you. EDIT: Never mind that plnkr, I found a working fiddle here http://jsfiddle.net/pEFy6/ It looks like it is the behavior of select2 to collapse to the width of first element. I could set the width through bootstrap class="input-medium" .Still not sure why angular