jquery-select2

Select2 - Sorting results by query

可紊 提交于 2020-01-10 13:11:10
问题 I'm using Select2 version 4.0.0. If my results contain multiple words, and the user enters one of those words, I want to display the results sorted by where the entered word is within the result. For example, a user enters "apple", and my results are: "banana orange apple" "banana apple orange" "apple banana orange" Then "apple banana orange" should appear first in the list of select2 results, because that is the result in which "apple" appears earliest within the result. I don't care so much

Prevent select2 from flipping the dropdown upward

≡放荡痞女 提交于 2020-01-10 07:31:57
问题 As per title, is there a way to force select2 to always create a dropdown instead of a drop-up? There also appears to be some javascript that is either causing the flip when you scroll above the dropdown, adding a new CSS class "select2-drop-above", or both. EDIT: I should've specified that I'm pulling the library in via select2-rails. I'm hoping there is a way around this that doesn't involve pulling the whole select2 lib in myself and editing the select2.js file directly. 回答1: Modifying the

Prevent select2 from flipping the dropdown upward

为君一笑 提交于 2020-01-10 07:31:11
问题 As per title, is there a way to force select2 to always create a dropdown instead of a drop-up? There also appears to be some javascript that is either causing the flip when you scroll above the dropdown, adding a new CSS class "select2-drop-above", or both. EDIT: I should've specified that I'm pulling the library in via select2-rails. I'm hoping there is a way around this that doesn't involve pulling the whole select2 lib in myself and editing the select2.js file directly. 回答1: Modifying the

when click on close button and when click on suggestions text with select2

喜夏-厌秋 提交于 2020-01-07 08:41:33
问题 I want check if a user click on select2 close button or only it's triggered a change event. This is my select2 input: <%= hidden_field_tag :query, params[:query], :id => "query_txt" %> On my coffeescript file: $('#query_txt').select2( #select2 options here, ajax, initSelection...etc # # # $("#query_txt").on "change", (e) -> if ($(".select2-search-choice-close").click ->) console.log "click on close" ) The problem is that if I click on suggestions text I can see the text "click on close" on my

passing selected value to jQuery's select2 ajax call

纵然是瞬间 提交于 2020-01-07 03:04:40
问题 I'm attempting to pass an extra parameter(the selected value) to an ajax call within multiple select2 : $("#ddlMultiCourse").select2({ placeholder: "Search for Course", minimumInputLength: 1, allowClear: true, ajax: { // instead of writing the function to execute the request we use Select2's convenient helper url: url,//GetCourseList type: "POST", dataType: 'json', delay: 250, data: function (params) { return { term: params.term, // search term value: $("#ddlMultiCourse").val()//extra

Coffeescript dynamically create/call a function from a list on select box value change

99封情书 提交于 2020-01-06 19:41:32
问题 I'm working on adding some image editing tools using the Pixastic library. The idea is that the user can choose an aspect of the image or tool they want from a select box, then the tool will show up below the select box (I'm using select2) and the user can edit via a slider. Here's what I have so far: # This seeds the select2 options list imageToolsList = [ {id: 'bl', text: 'Blur'} {id: 'bc', text: 'Brightness/Contrast'} {id: 'ca', text: 'Color Adjust (RGB)'} ... ] #Creates a select box and

jQuery Select2 plugin “view more…”, hidden search text field questions

会有一股神秘感。 提交于 2020-01-06 07:28:56
问题 I've a series of questions on jQuery Select2 plugin (I'm very new to Select2, just a day old): I'm getting data via AJAX call (using Select2's ajax feature) and am trying to figure out a way to add "view more..." option at the end of the dropdown display. Clicking on "view more..." has to take me to another separate search page. If I could get to the OnSuccess or OnComplete event of loading the AJAX call, I could then find the related DIV in the dropdown result and append "view more..." div.

Close ANY Select2 dropdowns via jQuery

萝らか妹 提交于 2020-01-06 06:10:14
问题 Anyone know how to close a Select2 programatically without knowing the ID ? Just basically, if there's a Select2 open, close it. (If someone opens a modal (containing a Select2), opens the dropdown, and then clicks away from / dimisses the modal, the modal closes but the Select2 continues to show until another click.) For instance, this works BUT you need to know the ID : // If a Modal is hidden, close the Select2 contained therein $(document).on('hide.bs.modal', '.modal', function() { $("

Bootstrap Select2 - Unable to populate via AJAX

泄露秘密 提交于 2020-01-05 08:00:31
问题 I need some help figuring out what I am doing incorrectly. I am trying to populate the dropdown with users from my database. I am using Codeigniter and Firebug is giving me the error: TypeError: j is undefined VIEW <input id="users" type="hidden"> <script> $("#users").select2({ width: "element", ajax: { url: "localhost/index.php/get_clients", dataType: 'json', data: function (term, page) { return { q: term }; }, results: function (data, page) { return { results: data }; } } }); </script>

how to retain Select2 results after select?

喜欢而已 提交于 2020-01-05 04:32:10
问题 For example, when using select2 muti-value, user entered ' new ', and it showed New Mexcio New Hampshire New Jersey New York After selecting ' New Mexcio ', and the user would like to select again from the rest of the 3 remaining. In order to to do that, the user has to enter 'new' again. Is there a way to retain the results instead of clear out the ' query ? Thanks 回答1: Sounds like you want to persist a query from one search to the next. You might want to check out the nextSearchTerm