If we load Requirejs before Stimul then get error. are there any way to use stimul in a requirejs module?
The error is:
Code: Select all
Uncaught ReferenceError: moment_mod is not defined
Code: Select all
Uncaught ReferenceError: moment_mod is not defined
Code: Select all
requirejs.config({
paths: {
"momentjs": '/Stimulsoft/scripts/moment',
"StimulsoftReports": '/Stimulsoft/scripts/stimulsoft.reports',
"StimulsoftViewer": '/Stimulsoft/scripts/stimulsoft.viewer',
"StimulsoftDesigner": '/Stimulsoft/scripts/stimulsoft.designer'
},
shim: {
'StimulsoftDesigner': ['StimulsoftViewer'],
'StimulsoftViewer': ['StimulsoftReports'],
'StimulsoftReports': ['momentjs']
}
});
Code: Select all
require(['StimulsoftDesigner'], function()
{
// use Stimulsoft here
});
Thanks, but not work for me:Barnaby wrote: ↑Wed Feb 06, 2019 3:14 am Hi, I ran into the same problem, and found a way to get it working.
You need to add and load momentjs before you load stimulsoft.reports.
I moved it all into requirejs, then made my requirejs config load it in this order: momentjs -> reports -> viewer -> designer
For exampleThen you would just need to define StimulsoftDesigner or StimulsoftViewer.Code: Select all
requirejs.config({ paths: { "momentjs": '/Stimulsoft/scripts/moment', "StimulsoftReports": '/Stimulsoft/scripts/stimulsoft.reports', "StimulsoftViewer": '/Stimulsoft/scripts/stimulsoft.viewer', "StimulsoftDesigner": '/Stimulsoft/scripts/stimulsoft.designer' }, shim: { 'StimulsoftDesigner': ['StimulsoftViewer'], 'StimulsoftViewer': ['StimulsoftReports'], 'StimulsoftReports': ['momentjs'] } });
Code: Select all
require(['StimulsoftDesigner'], function() { // use Stimulsoft here });
Code: Select all
require.config({
baseUrl: "@Url.Content("~/scripts/")",
urlArgs: function (id, url) {
var d = new Date().getTime();
return (url.indexOf('?') === -1 ? '?' : '&') + "vr=" + d;
},
paths: {
momentjs: "stimul/moment",
StimulsoftReports: "stimul/stimulsoft.reports",
StimulsoftViewer: "stimul/stimulsoft.viewer"
},
shim: {
StimulsoftViewer: ["StimulsoftReports"],
StimulsoftReports: ["momentjs"],
bootstrap: ["jquery"]
},
waitSeconds: 60
});
Code: Select all
window.moment_mod = moment;
Code: Select all
'momentAdapter': {
deps: ['momentjs']
},
'StimulsoftReports': {
deps: ['momentAdapter']
},
'StimulsoftViewer': {
deps: ['StimulsoftReports']
},
'StimulsoftDesigner': {
deps: ['StimulsoftViewer']
},
Code: Select all
// require my normal stuff
require(['Example'], function(Example)
{
// Temporarly remove the define.amd
var _amd = define.amd;
delete define.amd;
// Load the designer
require(['StimulsoftDesigner'], function()
{
// re-add the amd
define.amd = _amd;
// run designer code
});
});