jquery-select2

How to get the current input value which is entering on select 2 input field

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 05:14:00
问题 When i'm first time entering multi select values i got the current entered text value based on below code in jquery <select class="form-control select2" multiple="multiple" data-placeholder="Select areas" style="width: 100%;" id="edit_areas" name="area"> </select> $(".select2-search__field").val() $(document).on('keyup',".select2", function (e) { var city = $("#add_city option:selected").text(); var location = $(".select2-search__field").val();}); which works fine. But on edit when try to

Search text not displayed when Select2 changed to 'multiple' selection mode

梦想的初衷 提交于 2019-12-12 04:58:42
问题 To view the code base for problem statement, Kindly CLICK HERE as I set select with id='firmName' with multiple attribute, I am unable to see the text when I type to find specific firm. Below is the image to support my question. I type "ajinkyatara" in search box but unable to see it the text. How to show the search text string when select2 is in multiple selection mode. 回答1: I found out this post and its sad that it has nothing selected as a solution, as de OP mentioned in a comment this is

How to remove the dropdown item matching the currently typed text using the jQuery Select2 plugin?

╄→尐↘猪︶ㄣ 提交于 2019-12-12 04:37:27
问题 I'm using the select2 jQuery plugin with an ajax call to populate the dropdown selection menu as the user types. My input is configured for tagging, so multiple selections are allowed and the user can enter their own tags, so the dropdown items are just suggestions. The problem is that the whenever the user types, the first item in the dropdown list always matches what the user has typed. The items following that are the suggestions retrieved by ajax call. It's not unreasonable that this

How to default select2 in angularJS

家住魔仙堡 提交于 2019-12-12 04:07:08
问题 Instead using ui-select, I'm using jQuery select2 in AngularJS. I created custom directive for select2, for ng-model. I get the value from ng-model. But when I update the select2 on default, it doesn't work. I'm using select2 v4.0.3 . Directive App.directive('jsSelect2', function ($timeout) { return { link: function (scope, element, attrs) { jQuery(element).select2(); scope.$watch(attrs.ngModel, function(){ $timeout(function(){ element.trigger('change.select2'); },100); }); } }; }); HTML

Get Last Selected Value of Select2?

吃可爱长大的小学妹 提交于 2019-12-12 03:47:37
问题 I am using multiple options for Select2 and the data is loaded from a JSON source. As I'm not sure how to explain it exactly I'll provide an example: List Options: A B C If I choose C, then $("#select2").change(function(){ alert($(this).val()); }); Results: [C] However, If I then choose A I would get [A, C] If I then choose B I get [A, B, C] I would preferably want it to append so I would get [C, A, B]. However being able to find the last selected option would be alright. I have tried :last

Select2 - Deny to can clean the input field and disable the form if results not found

天涯浪子 提交于 2019-12-12 02:46:10
问题 I have this json file on /api/searches : [{"id":"513dbb61a61654a845000005","text":"ingeniero agrónomo"},{"id":"513a11d4a6165411b2000008","text":"ingeniero industrial"}] I'm using select2 to show results. This is my current select2 setting: $('#query_txt').select2 createSearchChoice: (term, data) -> if $(data).filter(-> @text.localeCompare(term) is 0 ).length is 0 id: term text: term width: 'resolve' minimumInputLength: 3 tags: true showSearchBox: true maximumSelectionSize: 1 closeOnSelect:

Set multiple Select2 options

故事扮演 提交于 2019-12-12 02:45:53
问题 I have a form to create new Objects, which gives the possibility to add multiple Keywords via a Select2. I use Symfony ; the Keywords are taken from an entity. Adding existing keyword in the Select2 list work perfectly fine. Now I want to give the user the possibility to add brand new keywords, and that those new keywords directly appears in the Select2 list. So I created a "Add Keyword" button on my "new object form", which leads to a "New Keyword" form (a Bootstrap modal window). The

Dynamic ChoiceType (select2 + AJAX)

拈花ヽ惹草 提交于 2019-12-11 17:59:28
问题 I need a form field to choose from thousands of entities, so a dynamic choice system like select2 (with AJAX) is perfectly suited. My AJAX endpoint works fine, but the custom form type does not work: class Select2AjaxDataCategoryType extends AbstractType { /** * @var EntityManagerInterface */ private $entityManager; /** * @var RouterInterface */ private $router; public function __construct(EntityManagerInterface $entityManager, RouterInterface $router) { $this->entityManager = $entityManager;

Vue 2 select2 custom template for label

老子叫甜甜 提交于 2019-12-11 15:15:32
问题 I know I can change the template for the option slot, but can we do the same for the label slot? Like for option : <v-select inputId="originsId" :options="origins" label="city" placeholder="Search..."> <template slot="option" slot-scope="origin"> <div class="flex"> <div class="col"> <span>{{ origin.city }}</span> </div> <div class="col"> <span>{{ origin.country }}</span> </div> </div> </template> </v-select> Is there some way I can style the label when the option is selected? Now it only

Select2 not loading remote data

我们两清 提交于 2019-12-11 13:46:51
问题 I'm having some issues with select2. I tried loading remote data by following API documentation, however I still get a load indicator, no errors, but no data is shown. Here is some code: https://gist.github.com/Fire-Dragon-DoL/5993136 Javascript: (function() { var $; $ = jQuery; $(function() { $('a.submit-link').on('click', function(ev) { ev.preventDefault(); $(this).closest('form').submit(); }); $('.spinner-float').spinner({ step: 0.01, numberFormat: 'n', min: 0 }); $('.spinner').spinner({