Я добавил плагин для множественного выбора в своем проекте Symfony 4.
Я установил файл CSS в мои активы CSS и файл JS в активы JS. Я загрузил все с webpackConfig.js.
//WebpackConfig.js : load is ok
.addEntry('multiselectjs', './assets/js/multiselect.js')
.addEntry('multiselectcss', './assets/css/multiselect.css')
/*app.js
* Welcome to your app's main JavaScript file!
*
* We recommend including the built version of this JavaScript file
* (and its CSS file) in your base layout (base.html.twig).
*/
// any CSS you require will output into a single css file (app.css in this case)
require('../css/app.scss');
// Need jQuery? Install it with "yarn add jquery", then uncomment to require it.
// const $ = require('jquery');
// loads the jquery package from node_modules
const $ = require('jquery');
global.$ = global.jQuery = $;
// this "modifies" the jquery module: adding behavior to it
// the bootstrap module doesn't export/return anything
require('bootstrap');
// or you can include specific pieces
// require('bootstrap/js/dist/tooltip');
// require('bootstrap/js/dist/popover');
$(document).ready(function() {
$('[data-toggle="popover"]').popover();
$('#my-select').multiSelect({keepOrder: true,
selectableHeader: '<span class="multiple-select-header">Groupes disponibles</span>',
selectionHeader : '<span class="multiple-select-header">Sélection</span>'
});
});
До этого все нормально, если я посмотрю на источники моей веб-страницы, файлы будут загружены правильно.
У меня проблема, хотя. Когда я вызываю функцию этого плагина, у меня возникает ошибка, сообщающая, что .multiselect () не является функцией.
-> jQuery.Deferred exception: $(...).multiSelect is not a function TypeError: $(...).multiSelect is not a function [...]
-> jquery.js:3850 Uncaught TypeError: $(...).multiSelect is not a function [...]
Не могли бы вы понять, что плохо загружено в том, что я сделал?