jquery-select2

Error placement, Select2

爱⌒轻易说出口 提交于 2019-12-25 03:32:20
问题 I have a problem with select2 error placement when I save a form containing one or many select2. Here is what I have: I have some Forms with some mandatory select2 inputs and they work fine showing the error with jQuery Validate but whatI want is the html to jump to the select2 with the error when I save the form. Currently the submit handler jumps just fine to any other element except the selectors. 回答1: I ended up overwriting the invalid handler and call the id of the select2:

javascript make select 2 use url set by outside source

懵懂的女人 提交于 2019-12-25 00:14:32
问题 I'm using select2 to pick out games from a database, however, the file I wish it to search from will change depending on what's selected from a dropdown. How do I get it so select2 always uses the most up to date "picker_url"? So if I select a certain option from a select box on a page, it changes the "picker_url" (an ajax file to do the search). The problem is, select2 only seems to use the original value. Here's my current code: var picker_url = "test1.php"; $(document).on('change', "

Select2 is slow on opening with 10.000+ elements

随声附和 提交于 2019-12-25 00:08:01
问题 I'm using Select2 to fill Dropdowns. Select2 is slow when opening its dropdown menu if the underlying select has a fair number of items. I have more than 10.000+ elements in my dropdown. Here is my code: $.ajax({ url: "/Companies/GetCompanies", method: "get", success: function (data) { if (data != null) { var newWorkPlaceId = $("#newWorkPlaceId"); newWorkPlaceId.empty(); newWorkPlaceId.append("<option value=''> -- Choose-- </option>"); $.each(data, function (index, item) { newWorkPlaceId

Set initial select2 height but allow it to expand vertically

为君一笑 提交于 2019-12-24 19:33:50
问题 I have a select2 box that I want to allow to expand upward, e.g. height: auto , but I also want to set its initial height, e.g. height: 34px . How can I accomplish this? If I try to set both of them, one overrides the other. I'm trying to have the box expand vertically as needed without adding a scrollbar. I've looked at other questions like this, but nowhere can I find how to allow the size to increase but start at an initial value. I've set a min-height , but auto doesn't shrink to fit mid

Symfony Assign multiple values at once in Bridge Entity Form

徘徊边缘 提交于 2019-12-24 19:04:06
问题 I have below relationship between my entities. One to many between Institute -> InstituteCourses . One to many between Courses -> InstituteCourses . I have avoid making many to many between instiutes and courses because i have alot more fields in instiutecourses entity. For now it is working well, class Institutes { /** * @ORM\OneToMany(targetEntity="InstitutesCourses", mappedBy="institute", cascade={"all"}) **/ protected $instituteCourses; } class Courses { /** * * @ORM\OneToMany

select2 from json based on other input field

老子叫甜甜 提交于 2019-12-24 18:29:40
问题 I need to populate a CITY select based on selection on PROVINCE with select2. I've some problems: 1- PROVINCE : It's populated by default, but i get duplicate elements. In my example i get: Milan Milan Torin Torin but i'd like to get: Milan Torin Solved by @david: http://jsfiddle.net/pe1u6Luo/282/ 2- Based on PROVINCE select, i need to populate CITY ONLY with subarray. For example if I select Milan on first select, i need to get CITY like: Rho Other city I don't know how to filter. Solved by

Change placeholder on link click in html

ぃ、小莉子 提交于 2019-12-24 18:23:19
问题 With below code I'm trying to change the placeholder for select element on link click. But no changes are seen as of now. Also I'm trying to figure out how to show div when click on gear icon. Currently it works when click on div but not for icon present in it. <!doctype html> <html lang="en"> <head> <!-- Dropdown - > https://stackoverflow.com/questions/43579748/how-to-achieve-autocomplete-feature-over-html-drop-down-or-select-element --> <!-- focus in-out event > https://stackoverflow.com

jquery-select2 always sends null params in controller

折月煮酒 提交于 2019-12-24 18:00:48
问题 I am using jquery-select2 to load the data with ajax. But jquery-select2 alwasy send null params to controller action Here is the agent.js code that i am using to search the data $('.chosen-select').select2({ minimumInputLength: 2, placeholder: "Search by Agency code, agent code, name or email", ajax: { url: "/dashboard/agent_invitations/search_agents", dataType: 'json', type: 'GET', data: function (term) { { q: term } }, processResults: function (data) { results: data.results } } }); agents

Select2: how to add a link instead of “No results found” text?

℡╲_俬逩灬. 提交于 2019-12-24 17:06:27
问题 Following is my code: $('#cow_id_2').select2({ allowClear: true, placeholder: "Search a cow/dam ID", formatNoMatches: function (term) { return "<a href=/'http://google.com/'>Add</a>"; } }); When I try to add a link the plugin just stop working. I am using Select2 4.0.3 version 回答1: If you're using version 4 or newer of select2, try this: $('#cow_id_2').select2({ allowClear: true, escapeMarkup: function (markup) { return markup; }, placeholder: "Search a cow/dam ID", language: { noResults:

Select2: how to add a link instead of “No results found” text?

感情迁移 提交于 2019-12-24 17:03:32
问题 Following is my code: $('#cow_id_2').select2({ allowClear: true, placeholder: "Search a cow/dam ID", formatNoMatches: function (term) { return "<a href=/'http://google.com/'>Add</a>"; } }); When I try to add a link the plugin just stop working. I am using Select2 4.0.3 version 回答1: If you're using version 4 or newer of select2, try this: $('#cow_id_2').select2({ allowClear: true, escapeMarkup: function (markup) { return markup; }, placeholder: "Search a cow/dam ID", language: { noResults: