Problem loading external libraries in surf pages

cancel
Showing results for 
Search instead for 
Did you mean: 
aalvarezfern
Member II

Problem loading external libraries in surf pages

Hello, Im new to alfresco5 and i m building some surf pages where i need to use some external libraries  on them (i.e.  dragula , datatables,etc)

 To load those libraries (not even try to use them) i use this directive in the html.ftl :

<@markup id="js">
<@script type="text/javascript" src="${page.url.context}/res/components/js/dragula.js"></@script>
</@>

dragula loading error

Well, it seems its not the proper way to load them since i get multipledefine errors browser 

I know the problem has to do with dojo, but i dont know exactly how make dojo load external libraries.

It s extrange since some custom javascripsi have made are loaded ok. 

Does any one know how to proper load  external javascripts avoiding dojo colisions?

2 Replies
afaust
Master

Re: Problem loading external libraries in surf pages

Are you trying to build a page using Aikau or YUI? If the former, you should try to load external libraries using the Dojo loader instead of using <@script> inclusions, which are only meant for the latter / legacy case. From looking at dragula, I can't see what should be causing this error - I don't see anything that would be defined multiple times just by including that library. I suspect the error may be caused by some other issue, i.e. are you trying to create a page with multiple Dojo-based components? In Aikau, the expectation is that only one component is using Dojo / Aikau, i.e. in legacy pages it is the share-header, in Aikau-pages it is the sole component bound to the page.

aalvarezfern
Member II

Re: Problem loading external libraries in surf pages

Thanks for your answer, i tried loading it with dojo  and it worked in almost  all libraries.There is ,still , a library that doesnt work yet (dragula).

I used this code to load it :

 require(["https://cdnjs.cloudflare.com/ajax/libs/dragula/3.7.2/dragula.js"], function(){
dragula([document.getElementById('left-defaults')]);
});

the library gets loaded correctly , but it doesnt work properly.But i think that this a problem out of the scope of this question. 

many thanks.