0

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

1 Answer 1

3

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.

1
  • glad to hear, would you please accept and upvote my answer?
    – andy
    Commented Jan 17, 2018 at 8:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.