jquery-select2

Styling individual select2 tags

浪子不回头ぞ 提交于 2019-12-23 03:53:16
问题 I'm trying to style individual select2 tags using Bootstrap's button styles ( .btn-primary and .btn-danger ) based on if the user created a tag (applying the red .btn-danger style) or if the user selected a existing tag (applying the blue .btn-primary style. I've tried to apply the style during the select event (select2:select) event: $("#ticker_select").on('select2:select', function(e) { // If the e.params.data.id equals e.params.data.txt, // then it is a user-created tag! if (e.params.data

Filling HTML Input Boxes That Were Created With Select2

大城市里の小女人 提交于 2019-12-23 03:23:10
问题 I'm using Excel VBA to automate a web page. The "Select" boxes and "Input" boxes were created by a jQuery platform called "Select2." When the user clicks on a "Select box" (which appears as an input box) a dropdown box pops up asking the user to type in two characters. I've discovered that you can add a valid data item into this box with this command by inserting the select box ID. myDoc.parentWindow.execScript "$('#s2id_broomCloset').val('Swiffer - Model 2010').trigger('change')" Most of the

jQuery Validate, Select2, and Bootstrap 3 Popovers - How to Bind Popover To Select2's Parent Elements Instead of Hidden Select Element

白昼怎懂夜的黑 提交于 2019-12-23 02:34:14
问题 I've implemented the excellent method to use Bootstrap 3's Popovers to show validation error messages, and for the most part it works well - except when it comes to hidden or replaced elements, like Select2 or CKEditor. The popover positions itself correctly on regular elements like input and normal selects, but not a select enhanced by Select 2. I've created a Fiddle that Sparky fixed so it actually works: http://jsfiddle.net/jemxtthb/4/ $("#noticeSentTo").select2(); var validator = $("

preloading external json into select box then after search getting specific results

守給你的承諾、 提交于 2019-12-23 02:28:09
问题 so i am looking into loading external data in an select2 box where there is prepopulate results from the json i have two issue - getting the data in and then only loading the first few but when a user searches it passes the request to the rest and then the specific json is returned so the HTML is a simple as <input type="hidden" id="e21" style="width:300px;"/> the inital js is $(document).ready(function () { $('#e21').select2({ query: function (query){ var data = {results: []}; console.log

How can I use multiple modified select2 selectboxes?

こ雲淡風輕ζ 提交于 2019-12-22 17:16:09
问题 I have a jquery code, that is resorting my select2 tags. It is working well: $('select').select2({ placeholder: 'Select a month' }); $("select").on("select2:select", function(evt) { var element = evt.params.data.element; var $element = $(element); window.setTimeout(function() { if ($("select").find(":selected").length > 1) { var $second = $("select").find(":selected").eq(-2); $element.detach(); $second.after($element); } else { $element.detach(); $("select").prepend($element); } $("select")

Two way databinding in Select2 for AngularJS doesn't work

☆樱花仙子☆ 提交于 2019-12-22 13:51:33
问题 I am having issues with using the Select2 plugin in AngularJS. I can load the items fine, and retrieve the selected item from my ng-model, but I have issues, that the dropdown isn't updated if I update the ng-model. In my view the code looks like this: <select ui-select2 data-placeholder="All" id="filtersSelect" ng-model="chosenFilterItem" ng-options="item.text for item in filterItems"> In my controller I have the following code, which retrieves the items and binds it to the list: $scope

How to insert FontAwesome inside Select2

邮差的信 提交于 2019-12-22 10:45:22
问题 I have no idea how to insert fontawesome inside Select2. What should I add the CSS or JS in it? I have a view like below. click : http://s10.postimg.org/675fig9vd/Capture121212121.png Can anyone help me? 回答1: Based on my plugin WP Mobile Splash Page Editor, I made a quick fiddle: http://jsfiddle.net/SiamKreative/qCn6p/ function format(icon) { var originalOption = icon.element; return '<i class="fa ' + $(originalOption).data('icon') + '"></i> ' + icon.text; } $('.wpmse_select2').select2({

Django - implementation of select2 with url

时光毁灭记忆、已成空白 提交于 2019-12-22 10:38:45
问题 I've added a select2 field to my webpage and I want to load the records into it using ajax. So I've declared a url field. $(document).ready(function() { $("#field_id").select2({ placeholder: "Search...", ajax: { url: '{{ url }}', dataType: 'json', ... templateResult: formatItem, This url points to a method, that should return the matching products, but I don't have any idea how to serialize them so that it works. This is my method: def get_ajax(self, request, *args, **kwargs): query = request

Using $(this) in select2

僤鯓⒐⒋嵵緔 提交于 2019-12-22 09:56:15
问题 I'm trying to read a collection from the html5 data-attribute of the input that is converted to select2 to create tags. This is working when I have one input: $(".tags").select2( width: '220px' tags: $(".tags").data('collection') ) But I will like to do it more safe using the data of the element itself, I tried this: $(".tags").select2( width: '220px' tags: $(this).data('collection') ) But it fails with the error: Uncaught query function not defined for Select2 investigador_aplicaciones Do

How to capture event when allowClear option of select2 is chosen?

故事扮演 提交于 2019-12-22 08:55:35
问题 I've tried to capture select2:clearing event $("#my-select").on("select2:clearing", function (e) { console.log('cleared'); }); (jsfiddle) but it is not fired. I've also tried other versions (like select2:removed etc., see another question with similar problem), but it also doesn't work. I use select2 4.0.0-beta2. 回答1: The changelog of select2 4.0.0-beta2 states: Removed events select2-clearing - Use select2:unselecting instead https://github.com/select2/select2/releases 回答2: This works: $("