I am developing an Alfresco surf page that uses dragula. As alfresco 5 uses dojo , i use dojo to load dragula library.
require(["${page.url.context}/res/components/js/dragula.js"], function(){
dragula([document.getElementById('left-defaults')]);
});
The library gets loaded ok but dragula is not being definded properly. If i try to use it, i get a not defined error in browser like this:
Uncaught ReferenceError: dragula is not defined
at extractar:388
at runFactory (dojo.js:1147)
at execModule (dojo.js:1275)
at dojo.js:1310
at guardCheckComplete (dojo.js:1290)
at checkComplete (dojo.js:1305)
at onLoadCallback (dojo.js:1471)
at HTMLScriptElement.onLoad (dojo.js:1720).
Some pics of my problem.
why is this happening? Do i have to use another way to load and use dragula?
Thanks in advance
Your code is missing formal parameter passed to callback function i.e.
require(["path/to/dragula.js"], function(dragula /*this is missing*/) {
// you can use dragula param here
...
});
Look at the dojo.require to observe that if you want refer to module loaded at N-th index in array passed as first param to require()
you need to provide formal parameters matching first N modules in array.