jquery-select2

Tab through elements using Enter key including select2

喜夏-厌秋 提交于 2020-04-18 06:12:49
问题 I am using following code to tab through form elements using enter key. Problem is that this code skip select2 elements. $('body').on('keydown', 'input, select', function(e) { if (e.key === "Enter") { var self = $(this), form = self.parents('form:eq(0)'), focusable, next; focusable = form.find('input,a,select,button,textarea').filter(':not([disabled]):not([tabindex="-1"]):visible'); next = focusable.eq(focusable.index(this)+1); if (next.length) { next.focus(); } else { //form.submit(); }

Convert Select2 array output to string

a 夏天 提交于 2020-04-17 22:00:59
问题 I am trying to convert select2 array to string to be used in form. Currently my output looks like this: ?source%5B%5D=x1&source%5B%5D=x2 i am looking to convert it to have comma separated string. I have tried to use 'string = source.join()' but output of my string is empty. %5B%5D=x1&source%5B%5D=x2&string= What I am trying to get is something like this: string%5B%5D=x1,x2 <form action="/action_page.php"> <select class="form-control select2" multiple="" id="source" name="source[]" style=

Convert Select2 array output to string

不打扰是莪最后的温柔 提交于 2020-04-17 22:00:44
问题 I am trying to convert select2 array to string to be used in form. Currently my output looks like this: ?source%5B%5D=x1&source%5B%5D=x2 i am looking to convert it to have comma separated string. I have tried to use 'string = source.join()' but output of my string is empty. %5B%5D=x1&source%5B%5D=x2&string= What I am trying to get is something like this: string%5B%5D=x1,x2 <form action="/action_page.php"> <select class="form-control select2" multiple="" id="source" name="source[]" style=

How to split and display from string to array for Select2 jquery?

大兔子大兔子 提交于 2020-04-11 18:30:35
问题 How to split and display from string to array for Select2 jquery? Current string that I get from DB is like this Michael,Anna,Sofea , hence how to split into array as Select2 format will read array to display the information, like this ["Michael","Anna","Sofea"] Console.log from API reading Current console.log after split is like below: But why the selected that come from DB does not appear in Select2 <select> selection? <div class="col-lg-10 col-sm-8"> <select type="text" class="form-control

How to split and display from string to array for Select2 jquery?

|▌冷眼眸甩不掉的悲伤 提交于 2020-04-11 18:30:34
问题 How to split and display from string to array for Select2 jquery? Current string that I get from DB is like this Michael,Anna,Sofea , hence how to split into array as Select2 format will read array to display the information, like this ["Michael","Anna","Sofea"] Console.log from API reading Current console.log after split is like below: But why the selected that come from DB does not appear in Select2 <select> selection? <div class="col-lg-10 col-sm-8"> <select type="text" class="form-control

how to implement select2 with lock selection

只谈情不闲聊 提交于 2020-04-11 03:14:25
问题 Hi guys I am trying to use select2 with one disabled value. I am trying to implement it like $('#select_currency').select2('data', preloaded_data); I have been reading about Lock selections but I am not able to implement it, could you please someone let me know how to implement it or is there any tutorial about it. Thank you. 回答1: You can easely add locked="locked" if you use v3.5 http://select2.github.io/select2/#locked-selections. But in v.4.x this functionality is removed. I've found

how to implement select2 with lock selection

穿精又带淫゛_ 提交于 2020-04-11 03:13:39
问题 Hi guys I am trying to use select2 with one disabled value. I am trying to implement it like $('#select_currency').select2('data', preloaded_data); I have been reading about Lock selections but I am not able to implement it, could you please someone let me know how to implement it or is there any tutorial about it. Thank you. 回答1: You can easely add locked="locked" if you use v3.5 http://select2.github.io/select2/#locked-selections. But in v.4.x this functionality is removed. I've found

select2 firing twice if initialized by class

橙三吉。 提交于 2020-03-26 04:39:30
问题 I've several dinamically generated select using a button, so i can identify it only by class. The problem is that when select2:selectevent is fired, alert if fired N times, and not only where i changed the value. How solve this? (I only can assign init plugin by class, no unique id) <a id="add">Add new</a> <div id="container"> </div> $(document).ready(function() { $("#add").on("click", function(e){ e.preventDefault(); $("#container").append('<select class="idFolder" name="idFolder[]"><option

select2 add class to selected option

半城伤御伤魂 提交于 2020-03-23 04:41:07
问题 I want to add class to option in select2, so after i click on suggest list item it will add custom class added-to-select-multiple to the main select structure. Here's example code: <select id="myselect2" multiple="multiple" style="width:50%;"> <option>One</option> <option>Another option</option> <option>Hello there</option> </select> After i click on first element of suggest list : _________ HTML output from inspect ___________________ <select id="myselect2" multiple="" style="width:50%;"

laravel Error: Array to string conversion

雨燕双飞 提交于 2020-03-21 06:43:35
问题 I have gone through every solution I could find over youtube, stakoverflow and other websites. I am using Select2 to add multiple roles but I a consistently getting the same error. <select id="role" name="role_id[]" multiple='multiple' class="form-control js-example-basic-multiple"> @foreach($roles as $role) <option value="{{$role->id}}">{{$role->name}}</option> @endforeach </select> DD function is showing perfect result but after that it shows error. It works perfectly untill I add [] with