jquery-select2

Rails 5 ask_as_taggable with select2

半腔热情 提交于 2019-12-02 08:12:51
I cannot see the effect of select2 in rails 5 form whether it's a text_field or select. does anyone know why the tag_list is not being populated. I can see that the tag_list has values but as you see in the snap below, it shows "No results found". Does select2 work with Rails 5 as I've tried several options? form: Select all will display all values into the box <%= f.label :tags, "Tags (separated by commas)" %> <%= f.text_field :tag_list, value: f.object.tag_list.each { |e| e} %> <input type="checkbox" id="checkbox" >Select All I made the text field simple instead of select2 and was able to

i want to use multiple select2 onchange function in a dynamic way

放肆的年华 提交于 2019-12-02 07:51:22
I want to put select2 function in my code but don't know where to put that .select2() function i have this .append($(<?php echo json_encode($property_address1); ?>)) my model ` function property_address1() { $query = $this->db->query('SELECT host,price,city,property_thumbnail, apartments_type, contactnumber, contactperson,photographlinks,emailid, propertyaddress FROM tbl_contacts')->result(); $output = '<select id="neww" class="property_add_ form-control">'; foreach ($query as $row) { //echo $row->location; $output .= "<option value='". $row->propertyaddress ."'"; $output .= " data

How to capture enter key press for select2

只愿长相守 提交于 2019-12-02 06:32:40
问题 I have a select2 dropdown for countries (multiselect). When user types keywords, it shows the related items in the menu. For e.g., if user types ind , the menu shows India and Indonesia . If the enter key is pressed, the first item ( India ) is selected. This is the default behavior. Now, I would like to select both the countries when user types ind and presses enter. $(".select2-search__field").on("keyup", function (e) { console.log(e.keyCode); if (e.keyCode == 13) { alert(); } }); With the

select2: “text is undefined” when getting json using ajax

人走茶凉 提交于 2019-12-02 06:02:25
问题 I'm having an issue when getting json results back to select2. My json does not return a result that has a "text" field so need to format the result so that select2 accepts "Name". This code works if the text field in the json is set to "text" but in this case, I cannot change the formatting of the json result (code outside my control). $("#e1").select2({ formatNoMatches: function(term) {return term +" does not match any items." }, ajax: { // instead of writing the function to execute the

Polymer select2 element

你。 提交于 2019-12-02 02:45:03
I am attempting to wrap the great select2 jquery widget ( https://github.com/ivaynberg/select2 ) in a Polymer element for easy reuse. I was able to get the select initialized correctly, but am running into issues after initialization. Specifically, when clicking the select to open it a type error is thrown in the select2 script when positioning the pop over. Here is a repo with the failing implementation: https://github.com/ivelander/x-select2 Has anyone had good success integrating Polymer with this select2 widget or jquery widgets in general? Any suggestions on how I might get this example

select2: “text is undefined” when getting json using ajax

断了今生、忘了曾经 提交于 2019-12-02 00:41:56
I'm having an issue when getting json results back to select2. My json does not return a result that has a "text" field so need to format the result so that select2 accepts "Name". This code works if the text field in the json is set to "text" but in this case, I cannot change the formatting of the json result (code outside my control). $("#e1").select2({ formatNoMatches: function(term) {return term +" does not match any items." }, ajax: { // instead of writing the function to execute the request we use Select2's convenient helper url: "localhost:1111/Items.json", dataType: 'jsonp', cache:

Pass array to val in Select2

杀马特。学长 韩版系。学妹 提交于 2019-12-02 00:40:35
问题 I have a problem to set the selected Values of my "Select2". When I pass the id values separated by commas it works. But if the pass like array doesn't work. this is my Select <select class="form-control" id="myselect" multiple="multiple"> <option id="1">Value1</option> <option id="2">Value2</option> <option id="3">Value3</option> <option id="4">Value4</option> <option id="5">Value5</option> </select> It works $("#myselect").select2().select2('val', [1,2,3]); but this dosn't work var array

Pass array to val in Select2

爷,独闯天下 提交于 2019-12-01 22:16:34
I have a problem to set the selected Values of my "Select2". When I pass the id values separated by commas it works. But if the pass like array doesn't work. this is my Select <select class="form-control" id="myselect" multiple="multiple"> <option id="1">Value1</option> <option id="2">Value2</option> <option id="3">Value3</option> <option id="4">Value4</option> <option id="5">Value5</option> </select> It works $("#myselect").select2().select2('val', [1,2,3]); but this dosn't work var array_selection = [1,2,3]; $("#myselect").select2().select2('val', [array_selection]); You are putting your

jquery select2 plugin how to get only the result 'myString%'

折月煮酒 提交于 2019-12-01 20:43:05
i'm using the jquery-select2 plugin but i'm wondering how can i get only results that begins with the typed keyword ( like 'myString%') The documentation actually provides an example for that: $("select").select2({ matcher: function(term, text) { return text.toUpperCase().indexOf(term.toUpperCase())==0; } }); The above matcher is case-insensitive, for case-sensitive remove both .toUpperCase() calls. 来源: https://stackoverflow.com/questions/15809594/jquery-select2-plugin-how-to-get-only-the-result-mystring

Different display value for selecte text using select2.js

醉酒当歌 提交于 2019-12-01 17:51:50
Trying to implement a custom select dropdown using select2 plugin Is it possible to have the selected value to display only the actual option 'value' instead of the text, so if I selected 'Australian Dollar', the selected text should only display 'AUD' My mark-up looks something like this: <select name="convert-to" id="convert-to"> <option value="AUD" data-currency="AUD">Australian Dollar</option> <option value="USD" selected="selected">US Dollar</option> <option value="JPY">Japanese Yen</option> <option value="EUR">Euro</option> <option value="GBP">British Pound</option> <option value="CAD"