jquery-select2

How can I pass option changes to Angular-UI ui-select2?

烈酒焚心 提交于 2019-12-11 04:43:22
问题 angular-ui's ui-select2 documentation shows that you can do something like the following: myAppModule.controller('MyController', function($scope) { $scope.select2Options = { allowClear:true }; }); <select ui-select2="select2Options" ng-model="select2"> <option value="one">First</option> <option value="two">Second</option> <option value="three">Third</option> </select> However, changes to $scope.select2Options after that point do nothing. It would be nice if ui-select2 would watch

Select2 not showing selected value

江枫思渺然 提交于 2019-12-11 03:37:37
问题 I have looked endlessly on here and everywhere else for a while, and I cannot figure out why my Select2 dropdown boxes aren't changing the value they display after I click it out of the dropdown. I am trying to style the woocommerce product selection boxes using Select2 - I have them all styled, but now they don't seem to actually work. How I am initializing my two boxes: <script src="https://code.jquery.com/jquery-2.1.4.js"></script> <link href="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0

Fire callback when selection was made with select2 4.0, and retrieve the value of last selection

亡梦爱人 提交于 2019-12-11 02:31:35
问题 I am using the latest version of Select2 (4.0), and can't find out how to fire an event when a selection was made, AND retrieve the last selected value(when working with select boxes where multiple selections is possible). In older versions of Select2, if I remember correctly, the "onchange" event of the select to which the plugin was attached fired when a selection was made, this doesn't work at the momment. I've managed to fire a javascript function when the select boxes selection changes,

Changing the background color of a select2 selection within the select field

为君一笑 提交于 2019-12-11 02:27:42
问题 I am using Select2 to setup multi-select tag type fields in my application. I know which CSS attribute changes the colors of the selection box once it is placed in the select field: selection box color .select2-container--default .select2-selection--multiple .select2-selection__choice { background-color: #e4e4e4; border: 1px solid #aaa; border-radius: 4px; cursor: default; float: left; margin-right: 5px; margin-top: 5px; padding: 0 5px } What I am trying to figure out is how to have this

select2-jquery: How to set maximumselectionsize dynamically

[亡魂溺海] 提交于 2019-12-11 00:08:54
问题 I've a requirement where I'll decide Max selections to be allowed in select2 ui.How can I do that. I tried by $('#ChnageLnk').on('click',function(){ $('#SelectD').select2({maximumselectionsize :1}); }); 回答1: Edit Sorry - just checked. The option should not be all lowercase - it should be camel case like so: $('#ChnageLnk').on('click',function(){ $('#SelectD').select2({ maximumSelectionSize: 1 }); }); Fiddle here. 回答2: Please, note that since version 4.0 of select2 they have changed

jquery select2: Uncaught query function not defined for Select2 tags

前提是你 提交于 2019-12-10 23:07:49
问题 I am using select2 plugin ver 3.5. It is working fine on php file. I am able to select value and able to save them in database. Scenario User save the data and after some time he/she wants to update/modify the data. then previously selected value should appear in the form. I am using Ajax to retrieve the data from database and it is working fine. Issue is i am not able to show selected data in select2 plugin. I searched on SO and found few relevant questions but i am not able to understand

How to add html placeholder to select2?

泪湿孤枕 提交于 2019-12-10 21:37:50
问题 I want to add one icon to placeholder like this $("#tag_list").select2({ allowClear: true, placeholder: "<i class='icon-group'></i>    inout your tags...", tags: ['a', 'b', 'c'], }); But it renders plain text in select2, so how to render html text for placeholder? 回答1: Select2 automatically escapes HTML markup. $("#tag_list").select2({ allowClear: true, placeholder: "<i class='icon-group'></i>    inout your tags...", tags: ['a', 'b', 'c'], escapeMarkup : function(markup) { return markup; } //

How to execute select2() function on dynamically created select list?

人盡茶涼 提交于 2019-12-10 20:54:22
问题 I am simply creating a select list dynamically on a button click and appending it to a div. It is working without a problem but when I want this select list to behave like searchable as expected for select2 it is not working. In below, I'm passing my select list into a method with an html helper named GGroupDropDownListForJavascript and the html result is like below. <select class="form-control input-xxlarge select2me" id="TagCategoryId" name="TagCategoryId"> <option value="cf1d7da6-f49f-47aa

jQuery Select2 - select same option multiple times

ぐ巨炮叔叔 提交于 2019-12-10 19:08:06
问题 I am trying to make a page in my website where I want to use this select2 (http://ivaynberg.github.io/select2/) plugin. My requirement is to include same "words" multiple times. My tags could be: Monthly_Rent, Monthly_Rent, commission, mortgage, commission Also when user loads the page, I want to maintain the order how user selected it before saving. Currently when I add any option, its removed from the list. How can I add it again? Another issue is, now if I want to remove "commission" which

Select2: Uncaught TypeError: options.results is not a function

谁都会走 提交于 2019-12-10 18:00:39
问题 I am attempting to do an AJAX call with the Select2 jquery plugin. The query seems to be working, but the issue occurs when .results() is called on the options object: Uncaught TypeError: options.results is not a function Here is my HTML: <input class="form-control" type="number" value="2125" name="topic_relation[source_topic_id]" id="topic_relation_source_topic_id" /> Here is my JS: $(document).ready(function() { $('#topic_relation_source_topic_id').select2({ minimumInputLength: 3, ajax: {