25
Views
5
Comments
JavaScript error
Question


At the moment I am developing a Reactive Web App and I am trying to inject the following JavaScript:


Up to this point it is going well, because the javascript is actually loading as you can see below:


The only problem is that I am getting a few JavaScript errors as you can see below. All these libraries are provided within the code above (like KnockoutJS) but for some reason OutSystems is not able to deal with this, while implementing the same code in a "normal" website is not giving any problems. Does anybody has an idea why this is happening? Thanks!


Ps: I already tried to append it to body and head and it does not make a difference.

mvp_badge
MVP
Rank: #19

Hi Bart,

Why not do it the OutSystems way:

https://success.outsystems.com/Documentation/11/Extensibility_and_Integration/JavaScript/Extend_Your_Mobile_and_Reactive_Apps_Using_JavaScript/Use_JavaScript_Code_from_an_External_Library

Is there a hard required to load those files remotely, and be dependent on their availability?

To dynamically load external script this should be the minimal code in for example the OnInitialize event of your screen in a JavaScript widget:


var head1 = document.getElementsByTagName('head')[0];
var script_src1= "your_js_url_with_parameters";
var new_script1 = document.createElement('script');
new_script1.type = 'text/javascript';
new_script1.src= script_src1;
head1.appendChild(new_script1);
 

Regards,

Daniel

mvp_badge
MVP
Rank: #19

Hi Bart,

I don't know without getting my hands dirty on the code, and don't have time for that.

But I have past experience with KendoJS, and it tries to do similar things as ReactJS, so not sure if there can be conflicting code between the two UI frameworks in respect to UI input bindings.

What I know of ReactJS that it will remove html elements added outside their libary that it doesn't know about, so maybe that is causing the problem.

The fact that the KO global variable is not correctly initiated with KendoJs sees to point in that direction.

Try to load the JS scripts the OutSystems way (as resources) then see if the problem still exists, I know it is not optimal but at least it could help you find out the root cause of the problem you have right now.

Regards,

Daniel