jquery-select2-4

How to add selectall using dropdownadapter on select2 v4

只愿长相守 提交于 2021-02-19 08:47:06
问题 I am not using require and trying to implement this. $(".js-example-data-ajax").select2({ ajax: { //url: "https://api.github.com/search/repositories", url: "<?=BASE_URL ?>api/corporate-performance-dashboard/get-customers", dataType: 'json', type : 'POST', delay: 250, data: function (params) { return { q: params.term, // search term page: params.page }; }, processResults: function (data, params) { // parse the results into the format expected by Select2 // since we are using custom formatting

Select 2 with bootstrap popover

天大地大妈咪最大 提交于 2021-02-11 15:20:54
问题 I try to set a bootstrap 3.5 popover on select2 4.0.1, but it seems it does not working: <input id="sampleInput" type="text" rel="popover" data-content="This is the body of Popover" data-original-title="Creativity Tuts" data-placement="auto" data-trigger="hover" /> <p/> <select id="selectb" data-content="This is the body of Popover" data-original-title="Creativity Tuts" data-placement="auto" data-trigger="hover" data-container="body"> <option>Please select ...</option> <option value="1"

Multiple select element using select2 does not work properly

情到浓时终转凉″ 提交于 2021-01-03 08:36:09
问题 Please note that this is not about <select> element with multiple attribute, but multiple <select> s in a form, which I haven't found asked here. See this codepen I have two <select> element with unique ids and names. On both element I've also used select2. I was expecting the two would have initiated the same behavior hence the same jQuery code. The two did start the select2 but the later was not showing any option included in the <option> tags. It only shows the "No result found" message.

How to render html in select2 options

扶醉桌前 提交于 2020-07-31 09:24:00
问题 In this example of data loaded from a remote source I can see images and other html elements rendered as options. I'd like to accomplish the same thing using data in a local array. I've tried building an array as described in the documentation and adding it with the data option but the html is rendered as plaintext: var data = [ { id: 0, text: '<div style="color:green">enhancement</div>' }, { id: 1, text: '<div style="color:red">bug</div><div><small>This is some small text on a new line<

How to render html in select2 options

南笙酒味 提交于 2020-07-31 09:23:53
问题 In this example of data loaded from a remote source I can see images and other html elements rendered as options. I'd like to accomplish the same thing using data in a local array. I've tried building an array as described in the documentation and adding it with the data option but the html is rendered as plaintext: var data = [ { id: 0, text: '<div style="color:green">enhancement</div>' }, { id: 1, text: '<div style="color:red">bug</div><div><small>This is some small text on a new line<

How to render html in select2 options

元气小坏坏 提交于 2020-07-31 09:19:25
问题 In this example of data loaded from a remote source I can see images and other html elements rendered as options. I'd like to accomplish the same thing using data in a local array. I've tried building an array as described in the documentation and adding it with the data option but the html is rendered as plaintext: var data = [ { id: 0, text: '<div style="color:green">enhancement</div>' }, { id: 1, text: '<div style="color:red">bug</div><div><small>This is some small text on a new line<

Is there a way to add a description to each option in a dropdown using select2?

佐手、 提交于 2020-06-26 19:43:27
问题 I have a Django project in which I have a select dropdown like this: But I want something like this: My <select> form looks like so: (after inspecting in developer tools) <select class="form-control" data-parsley-required="true" id="id_org_role" name="org_role" required=""> <option value="A">Administrator</option> <option value="M" selected="selected">Member</option> </select> If not select2, is there any other jquery library that can help me accomplish this? I have tried following the

How do you modify “No Results Found” language in Select2 v4.0

北城以北 提交于 2020-06-22 05:28:49
问题 I attempted to use the "language.noMatches" option when initiating Select2 and its throwing an undefined function? How do I go about modifying that bit of text? I would like to include a html button that would add the input from the user if it wasn't found. I tried doing this as a function as well as plain text. I also removed all html to see if that was doing it. $('#search-select').select2({ ... "language": { "noMatches": function(){ return "No Results Found <a href='#' class='btn btn

Select2 shows flashing 'multiple' scrollbar until ready()

可紊 提交于 2020-05-16 22:00:22
问题 When I use a multiple select2 element, it very short show a vertical scrollbar (HTML Select) until the ready() is called and the element is changed. This can even be observed at the website https://select2.org/getting-started/basic-usage. If you scroll to the multiple-combobox, and hit Refresh you very shortly see the traditional scrollbar on the right. Is there a way to prevent this? Thanks 回答1: The issue is because the default select element is overflowed. This is why you see the scrollbar

Select2 4 custom data adapter

試著忘記壹切 提交于 2020-01-22 14:39:29
问题 I am trying to create a custom data adapter according to an example here: http://select2.github.io/announcements-4.0.html#query-to-data-adapter. How can I move the line that creates the select2 control outside the function with definition of DataAdapter (see the code below)? <!DOCTYPE html> <head> <title></title> <link href="select2.css" rel="stylesheet" /> <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.4.js"></script> <script type="text/javascript" src="select2.full.js