简体   繁体   中英

dragula loaded but not working

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.

dragula library loaded ok

dragula browser error

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 ie

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM