Currently JQuery is working fine with RequireJS. I now tried to use the jScrollPane plugin for JQuery. This plugin depends on the mousewheel plugin, so both have to be loaded. Since both plugins support AMD this shouldn't be a big problem.
I tried multiple solutions including
require(['jquery.jscrollpane','jquery.mousewheel'], function(JScrollPane) {
$(function()
{
$('.scroll-pane').jScrollPane();
});
});
and
// At the beginning of main.js
requirejs.config({
"shim": {
"jquery.jscrollpane": ["jquery"],
"jquery.mousewheel": ["jquery"]
}
});
// Later in another script
define(["jquery", "jquery.mousewheel", "jquery.jscrollpane"], function($) {
$(function()
{
$('.scroll-pane').jScrollPane();
});
});
but nothing is working. Using the JavaScript debugger in Chrome the callback function is never called and no error is thrown. The files are called jquery.jscrollpane.js and jquery.mousewheel.js and are placed in the same folder as RequireJS and JQuery.
Also it should be possible to load the plugins only once since they just extend JQuery, but I haven't found an example for that.
What am I doing wrong?
Since both plugins support AMD you shouldn't use a shim config.
Also, while creating the snippet below, I noticed that the scroll pane doesn't work if the
.scroll-panecontainer has text only and nopelements.