.multiselect不是函数,插件加载错误?

时间:2019-07-04 09:45:10

标签: jquery plugins symfony4 multi-select

我在Symfony 4项目中为multiselect添加了一个插件。 我在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 [...]

您会知道我所做的工作中有哪些内容不好吗?

0 个答案:

没有答案