jquery-select2

Jquery bootstrap select2 plugin issue with validate plugin

隐身守侯 提交于 2019-11-29 23:47:13
问题 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<

Resetting Select2 value in dropdown with reset button

会有一股神秘感。 提交于 2019-11-29 20:33:32
What would be the best way to reset the selected item to default? I'm using Select2 library and when using a normal button type="reset" , the value in the dropdown doesn't reset. So when I press my button I want "All" to be shown again. jQuery $("#d").select2(); html <select id="d" name="d"> <option selected disabled>All</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> I'd try something like this: $(function(){ $("#searchclear").click(function(){ $("#d").select2('val', 'All'); }); }); You can also reset select2 value using $(function() {

Select2 not working inside bootstrap modal

扶醉桌前 提交于 2019-11-29 19:07:07
问题 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.

Select2 Event for creating a new tag

♀尐吖头ヾ 提交于 2019-11-29 17:45:57
问题 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. 回答1: I can

set json data from ajax and make it serarchable in select2 jQuery

末鹿安然 提交于 2019-11-29 17:35:53
I had two drop down input fields, both are implementing Select2 Jquery. Here i set the data as static for first drop down . its works fine . As per selection of value in first drop down, next drop down will filled by another set of json data by ajax. I need to second drop down should be searchable with only once loaded the ajax data. but i am not get correctly. i not able to make it workable. i used the following scripts function format(item) { return item.name; } var data=[{"id":"1995","name":"Banahatti"},{"id":"5074","name":"Kolhapur(Maharashtra)"},{"id":"2356","name":"Sangola"},{"id":"906",

Override Minimum length string of Select2

拟墨画扇 提交于 2019-11-29 16:39:30
问题 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. 回答1: 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

How to automatically increase the height of select2 input box (multiple)

做~自己de王妃 提交于 2019-11-29 15:45:44
I have a select2 input box for multiselet option in which, user can select as many options as he wants, if the selected options are occupying more space than available width then I wanted to increase the height of the select box automatically (don't want scroll option, all options should be in viewable space) and get the remaining options in next line. Currently options are coming in the next line but the height of the select box is not increased. If I remove the height property in the .select2-container--default .select2-selection--multiple class, it is working. But I want this height

Aurelia trying to load HTML from Select2?

青春壹個敷衍的年華 提交于 2019-11-29 15:07:27
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> element? How can I fix this? Thanks The purpose of <require from="...."></require> is to import a view

Extending EntityType to allow extra choices set with AJAX calls

一个人想着一个人 提交于 2019-11-29 14:53:03
问题 I try to create a Symfony Custom type extending the core " entity " type. But I want to use it with Select2 version 4.0.0 (ajax now works with "select" html element and not with hidden "input" like before). This type should create an empty select instead of the full list of entities by the extended "entity" type. This works by setting the option (see configureOption): 'choices'=>array() By editing the object attached to the form it should populate the select with the current data of the

select2 change background color

梦想与她 提交于 2019-11-29 13:43:33
I am trying to use select2 on a webpage I am creating. However the combobox background seems to be transparent but I need to change it to another color. I tried modifying the select2.css file but nothing seems to work. Any Ideas ? If you are trying to target the combo box wrapper use .select2-search { background-color: #00f; } If you are trying to target the input use .select2-search input { background-color: #00f; } And if you are trying to target the results wrapper use .select2-results { background-color: #00f; } Hope this helps! It's a little late to help the OP, but I'll leave this answer