lndl / select2_simple_form Goto Github PK
View Code? Open in Web Editor NEWSelect2 inputs for SimpleForm
License: MIT License
Select2 inputs for SimpleForm
License: MIT License
I could get the right result set, but when I click any element of it, It's no any response
All of my feature specs fail when using this gem, due to the error in the title.
var Select2SimpleForm = (function($) {
'use strict';
var prepareSelect2Options = function(options, $input) {
var select2Options = {};
var sanitizeInputValues = function(input) {
return input.val().replace(/[|]|"|'/g, '');
Hi,
Impossible to install the gem when I try to bundle
, have this message:
Could not find gem 'select2-simpleform' in any of the gem sources listed in your Gemfile.
When using this gem with an AJAX-fed select2 instance, if the text
for a result
doesn't contain any HTML tags, the regexp defined here in the custom matcher won't match the text, thus making the .match()
call return a null
value, and finally causing a TypeError to be thrown when .index
is called on null
.
I am getting the following error when implementing a select2 with SimpleForm and this gem:
Cannot read property 'util' of undefined
This is the offending line:
var stripDiacritics = window.Select2.util.stripDiacritics;
JS error in console:
initializers.select2_simple_form.self-3b52a09c2e096725f4dfa3a398c74cc1a370d8b810a433a627531d241f5eef4a.js?body=1:42 Uncaught TypeError: Cannot read property 'util' of undefined
at prepareSelect2Options (initializers.select2_simple_form.self-3b52a09c2e096725f4dfa3a398c74cc1a370d8b810a433a627531d241f5eef4a.js?body=1:42)
at HTMLSelectElement. (initializers.select2_simple_form.self-3b52a09c2e096725f4dfa3a398c74cc1a370d8b810a433a627531d241f5eef4a.js?body=1:137)
at Function.each (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:371)
at jQuery.fn.init.each (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:138)
at HTMLDocument.initializeSelect2SimpleForm (initializers.select2_simple_form.self-3b52a09c2e096725f4dfa3a398c74cc1a370d8b810a433a627531d241f5eef4a.js?body=1:134)
at HTMLDocument.dispatch (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:5227)
at HTMLDocument.elemData.handle (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:4879)
at Object.trigger (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:5131)
at jQuery.fn.init.triggerHandler (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:5867)
at Function.ready (jquery.self-bd7ddd393353a8d2480a622e80342adf488fb6006d667e8b42e4c0073393abee.js?body=1:3587)
How do I handle with select2 data that does not have id
and text
fields?
Data like this will work:
var data = [
{
id: 0,
text: 'enhancement'
},
{
id: 1,
text: 'bug'
},
{
id: 2,
text: 'duplicate'
},
{
id: 3,
text: 'invalid'
},
{
id: 4,
text: 'wontfix'
}
];
$('#request_for_proposal_geo_path_counties').select2({
theme: "bootstrap",
data: data
});
But data like this won't:
var data = [
{
"fips": "02",
"name": "Alaska",
"zip_codes": [],
"counties": [],
"population_0": 752680,
"population_5": 698356,
"population_18": 565916,
"population_21": 534794
},
{
Good morning.
I'm using select2_simple_form in combination with cocoon in order to deal with nested models. The problem that I've foud is that each time a new nested record is added select2 inputs for this row do now correctly initializes the select2 inputs. I'm trying with this code, but without much success:
$("form").on("cocoon:after-insert", function(_, row) {
var select = row.find('.place_scheduled_tasks_chemical_product_ids').find('select');
if (select.length) {
Select2SimpleForm.init({allow_html: true}, select);
}
});
How can I use the Select2SimpleForm class in order to initialize input added dynamically to a form? Is there a place where I can find any documentation regarding to it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.