jquery-select2

Angular ui-select2 - hide initial drawing/rendering of component

旧巷老猫 提交于 2019-12-11 13:19:24
问题 I'm evaluating using Angular with ui-select2 and wondered whether someone could provide help on hiding the flicker/conversion of the <select> into the select2 component. It's only very brief, but users can see the component change styles. Is there a way of hiding it until the select has been modified by select2? 回答1: I came across the same problem and I had a look at the source code. The directive is deliberately initialised later by using a timeout. In the code there is a comment saying

How to update select2 drop down in codeigniter

痴心易碎 提交于 2019-12-11 12:17:18
问题 Hi i am using select2 jquery plugin to insert multiple values to a drop down but when i am trying to update i am facing problem can anyone help me out in showing the right way of doing this <?php $cats = explode(',',$r['keyword_whomtoteach']); foreach($cats as $vald) { foreach($keyword as $key=>$keywords) { if ($vald == $keywords->keyword_id) { ?> <option value="<?php echo $keywords->keyword_id; ?>" <?php { echo "selected"; } ?>><?php echo $keywords->keyword_name; ?></option> <?php } else { ?

Is it possible to disable opening on key enter for select 2 (v 4.0.3)

房东的猫 提交于 2019-12-11 12:06:50
问题 Is it possible to disable opening on key enter for select 2 (v 4.0.3). I found somewhere that it can be done with options "openOnEnter: false", but it does not work for me. 回答1: Unfortunately, no. At the time of version 4.0.3 at least. It's hardcoded: this.on('keypress', function (evt) { var key = evt.which; if (self.isOpen()) { // skipped } else { if (key === KEYS.ENTER || key === KEYS.SPACE || (key === KEYS.DOWN && evt.altKey)) { self.open(); evt.preventDefault(); } } }); 回答2: The behaviour

jquery select2 plugin how to match only beginning of word

若如初见. 提交于 2019-12-11 11:47:25
问题 I am using select2 in my website and i want the autocomplete to match only the beginning of the word. For example, if I type "CA" I want CAmeroun to appear and not "vatiCAn". 回答1: I figured out how to resolve this by searching in the documentation (here https://github.com/select2/select2/issues/428). In select2 library, replace in select2.js : matcher: function(term, text) { return stripDiacritics(''+text).toUpperCase().indexOf(stripDiacritics(''+term).toUpperCase()) >= 0; }, by : matcher:

How to have different link

六月ゝ 毕业季﹏ 提交于 2019-12-11 10:47:23
问题 I am new in JS > jQuery > select2 and ... english language! My problem: I would like that the link in http://jsfiddle.net/JfWtJ/1/ is dynamic. So, in first time, I test : function format(state) { return state.text + "<a class='info' target='_blank' href='http://obs43/test.php?param="+state.id+"' >link</a>"; } (see http://jsfiddle.net/7J8Ag/) but it's not ok. In second time, I test http://jsfiddle.net/7J8Ag/1/ with: $("#select").on('open', function() { $('.select2-results i').on('mouseup',

How to get data attribute of <select> for use in select2 from inside .select2() ajax call?

只谈情不闲聊 提交于 2019-12-11 10:43:22
问题 I need to know what element my select2 UI is based on so that I can grab data from a data-attribute. Maybe I'm missing it in the docs, but I can't seem to figure out how to get it. Here is the basics of how my code is set up: <form> <!--SNIP--> <select class="select-records" data-index=0> <option>Choose some records</option> </select> <!--SNIP--> </form> <script> $('.select-records').select2({ ajax: { url: "/ajax/records", dataType: 'json', delay: 250, data: function (params) { // Need to get

Nested Select2 with dependent AJAX call

半城伤御伤魂 提交于 2019-12-11 09:54:06
问题 I'm using Select2 with jQuery to build a dependent relationship between SELECT elements on a form. I'm trying to build the typically relation: Country has States, States has Cities, City has Town and so on. Right now I'm doing in this way: $(document).ready(function() { $(".pais").on('change', function() { pais = $(this).find('option:selected').val(); $.get(Routing.generate('estados', {pais_id: pais})).success(function(data) { if (data.message === "") { $('.estado').empty().append('<option

speed up select2 using ajax with php

烈酒焚心 提交于 2019-12-11 09:38:31
问题 I am trying to speed up my select2 results as i have over six-thousand customers in the database. I have the input box filled with data from a mysql database and dont know what more I can try at this stage to be honest. here is my select2 javascript (Js just isnt my thing) <script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.min.js"></script> <script type="text/javascript"> $(function(){ // turn the element to select2 select style $(".js-data-example-ajax").select2( { ajax:

Customize select2 multi select

送分小仙女□ 提交于 2019-12-11 07:29:06
问题 I'm creating a multi select field using select2 as follows. I want to make it so the placeholder ("Search items") always seen in the field even after I already select items. I tried this to put new placeholder after I select any choice on the dropdown: $(".select2-results__option").click(function() { console.log("x"); $(document).find(".select2-search--inline .select2-search__field").attr("placeholder", "Search items"); }); But unfortunately it doesn't even trigger the console log. My other

Click and Change event not working for jquery-select2 options

风流意气都作罢 提交于 2019-12-11 04:54:20
问题 I am using jquery-select2 library to implement my dropdowns. In my case, I would like to be able to trigger an action after a user clicks on the option in the dropdown list. However, the click or change event doesn't seem to work haml file: %select.medium.name_selector.pull_left %option.placeholder{value:"placeholder", disabled: "disabled", selected: "selected"} Start or find a conversation with a muser %option{value: "nick"} nick %option{value: "sam"} sam %option{value: "john} john