I have add my requirejs-config.js
app/design/frontend/Altravista/my_theme/requirejs-config.js
var config = {
deps: [
'js/custom'
],
paths: {
'select2': 'js/select2/select2.min'
},
shim: {
'select2': {
'deps': ['jquery']
}
}
};
I have my custom js file in
app/design/frontend/Altravista/my_theme/web/js/custom.js
define([
"jquery",
"select2",
"domReady!"
],
function($, select2) {
"use strict";
$( function (){
$('select').select2();
console.log('my_log');
});
});
but select2 does not start.
- custom.js is loaded (I can see my log in console)
- If i write jQuery('select').select2(); in console select2 works
PS: I have try also with selectize.js plugin and I have the same problem
if I use a scroll jquery event it works (start on scroll of page) so it is not a script error
$(function(){
$(window).scroll(function(){
// $('select').selectize({
// create: true,
// sortField: 'text'
// });
$('select').select2(
{
width: 'resolve',
closeOnSelect: true,
minimumResultsForSearch: -1
}
);
console.log('Hey!');
});
});
my custom.js file is loaded before select2.min.js