jquery-select2-4

How to make a Select2 4.0 sortable?

被刻印的时光 ゝ 提交于 2019-12-13 01:27:06
问题 I had this problem with the new version 4.0, and wasn't able to find any answer, until I myself solved with a work around after some hours of work. 回答1: My workaround solution: First, make it sortable with jquery. $("#mySelect").parent().find("ul.select2-selection__rendered").sortable({ containment: 'parent', update: function() { orderSortedValues(); } }); The function orderSortedValues has the following idea: Change the order of the options of the original select input, and notifying select2

Select2 v4 clone don't pass the data

﹥>﹥吖頭↗ 提交于 2019-12-13 00:15:34
问题 I am attempting to do an AJAX call with the Select2 ver4 jquery plugin and Using Loading remote data of Select2 sample page. I am trying to clone a select which contains select2 tool. Before Question Clone select have already worked by good Adviser!!Thank you!! But clone element don't work use new AJAX(test.php). HTML CODE <tr> <td> <select class="js-example-data-ajax" id="sel1"> </select> </td> <td> <div class="hint">Get befor select value.</div> </td> <td> <button type="button" class=

Select2: Hide certain optgroup dynamically

别来无恙 提交于 2019-12-12 20:43:12
问题 I need to hide/show a certain option group (<optgroup>) conditionally and I've tried the top solution from this question - Select2: Hide certain options dynamically It hides every option (as required), but group title stays visible, although it has no child items. How to hide the whole option group in select2? 回答1: I think you can disable <optgroup> in Select2 only using data array source, not using options in HTML. See issues on Select2 github repo: https://github.com/select2/select2/issues

Set tag value on select2

夙愿已清 提交于 2019-12-12 04:26:26
问题 I have select field on my page: <label> <span>Select name</span> <select name="name"> <option value="Option1">Option 1</option> <option value="Option2">Option 2</option> </select> </label> And I have initialized select2 lib for this field: $("[name='name']").select2({ allowClear: true, tags: true }); As you can see I need to use tags because user can write an option, not included in the proposed. And it works. When I want to set the default user value I use this command: $("[name='name']")

How to default select2 in angularJS

家住魔仙堡 提交于 2019-12-12 04:07:08
问题 Instead using ui-select, I'm using jQuery select2 in AngularJS. I created custom directive for select2, for ng-model. I get the value from ng-model. But when I update the select2 on default, it doesn't work. I'm using select2 v4.0.3 . Directive App.directive('jsSelect2', function ($timeout) { return { link: function (scope, element, attrs) { jQuery(element).select2(); scope.$watch(attrs.ngModel, function(){ $timeout(function(){ element.trigger('change.select2'); },100); }); } }; }); HTML

Select2 doesn't render properly

为君一笑 提交于 2019-12-12 03:54:13
问题 I am attemping to add Select2 library to my project, but I am failing miserably: My code looks like this: <head> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <link ref="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css"> <link ref="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs

Dynamic ChoiceType (select2 + AJAX)

拈花ヽ惹草 提交于 2019-12-11 17:59:28
问题 I need a form field to choose from thousands of entities, so a dynamic choice system like select2 (with AJAX) is perfectly suited. My AJAX endpoint works fine, but the custom form type does not work: class Select2AjaxDataCategoryType extends AbstractType { /** * @var EntityManagerInterface */ private $entityManager; /** * @var RouterInterface */ private $router; public function __construct(EntityManagerInterface $entityManager, RouterInterface $router) { $this->entityManager = $entityManager;

JqGrid searchoptions with select2 existing value

ぐ巨炮叔叔 提交于 2019-12-11 09:41:19
问题 I'm trying to integrate select2 for JqGrid filter form. I'm using JqGrid min 4.6 & Select2 min 4.0.1. The filter works fine but I'm unable to retrieve the value that has been set through select2 once the filter form is closed and reopened. i.e. dataInit e1 does not return the existing value of the select input. I must be doing something wrong? JqGrid Column Model: { name: 'CurrencyID', hidden: true, search: true, stype: 'select', searchtype: 'number', searchoptions: { searchhidden: true, sopt

npm browserify version of jquery-select2 version 4.x

孤街醉人 提交于 2019-12-11 04:26:01
问题 I was wondering if : There is a browserif'ied version of jquery-select2 4.x plugin available via npm? If not, what do I need to do in order to get jquery-select2 4.x to work with my npm/browserify based project? I was looking at the source on github and it seems like there is a require/almond.js version available. Can the same version be used with browserify without any changes? I'm slightly confused as to what exactly am I required to do if I want to use jquery-select2 plugin with my project

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,