Hello everybody !
I would like to make available an external JS library for all widgets so I followed this documentation here but I did not manage to implement ... My library is not recovered !
It is functional forall because I managed to use it for a single widget but my problem is to make it available for all I am afraid that the doc is not updated or I forget something!
Someone could refer me about the procedure?
thank you in advance !
Solved! Go to Solution.
Florian,
By putting window.path + 'libs/canvasjs/canvasjs.js' into the resources array in init.js file, the WAB should load the canvasjs.js file from the libs/canvasjs folder relative to the init.js file.
So, the init.js file configuration should be fine.
I am not sure with the custom widget sample code snippet you send.
What does the [...] and 'CanvasJS' in define mean?
Your custom widget doesn't need to load CanvasJS dependency, because the CanvasJS should be already available at global scope.
Your custom widget:
define([
'dojo/_base/declare',
'jimu/BaseWidget'
], function (declare, BaseWidget) {
return declare([BaseWidget], {
startup: function() {
console.log('CanvasJS=', CanvasJS);
}
});
});
Oh ?! I just created a new application to see if there wasn't a problem with the file's refreshing system and on this new application it works perfectly! (not a caching problem, I clean all my navigator's files after this discovery but didn't work with the first app)
--------------------------------------------------------------------------------------------------------------------------
[...] mean that there wasn't significant text and the canvasjs in the define it was a mistake by myself !
--------------------------------------------------------------------------------------------------------------------------
This behavior is strange but anyway thank you very much for your help!