Uncaught ReferenceError: Wisej is not defined

Answered
0
0

Hi guys.

I have been hit by the error “Uncaught ReferenceError: Wisej is not defined” at a specific situation.

I have an Exit button which the user can click to exit the application. At this point I call Application.Exit() and I also have my Default.json set with “autoReload”: true. So, the user clicks Exit, the application Exits and Reloads itself. Works great. But at times, I don’t know what might be going on, at Reloading it will throw an error inside my Default.html, which has code to show a Splash screen and then carry on. I have attached a print screen from the Chrome Console at the time the exception is thrown.

Any ideas of what could be going on?

Thanks in advance.

Ivan
(Wisej 2.2.44.0 – C# – SQL Server)

Attachment
  • You must to post comments
Best Answer
0
0

That means that for some reason the <script> tag is running before the script tag in the head which shouldn’t happen. Try to put Wisej.onLoad = inside the first setTimeout or add

Wisej = Wisej || {}

at the top of your script.

  • You must to post comments
0
0

Hi Luca.

I have this .js (DashboardClient.js) in my project in order to use the DevEx dashboard:


// load JSZip.
var script = document.createElement('script');
script.src = "https://cdnjs.cloudflare.com/ajax/libs/jszip/2.6.0/jszip.min.js";
document.head.appendChild(script);

Could this be affecting the Reload in some way?

  • Luca (ITG)
    Maybe. The document script is being executed before the wisej.wx script loads. If you add Wisej = Wisej || {} (first solution) it should always work.
  • Ivan Borges
    I tried it. Got the same error.
  • You must to post comments
0
0

Really strange… it happened again, now inside the first setTimeout.
Image attached.

Attachment
  • Luca (ITG)
    That means a timeout of 1 too fast and the browser is loading async which it shouldn’t (unless you added async to script wisej.wx. The other method should solve it.
  • Ivan Borges
    Thank you, Luca. I will try that. I have asyncs running in the main Page that could be running by the time the user clicks Exit. But I don’t have any async in the script. I don’t even know how to add async to script wisej.wx . :-)
  • You must to post comments
0
0

Thank you Luca.

I added your second advice to the script. Below is what you meant, right?



<!--
carregando...
-->
 
 
Wisej = Wisej || {} var splash = document.getElementById("splash"); var loadingProgress = document.getElementById("loading-progress"); splash.style.opacity = 1; setTimeout(function () { loadingProgress.style.width = "100%"; loadingProgress.style.left = "0%"; setTimeout(function () { loadingProgress.style.width = "0%"; loadingProgress.style.left = "100%"; }, 3000); }, 1); Wisej.onLoad = function () { var splash = document.getElementById("splash"); splash.parentNode.removeChild(splash); }
  • Luca (ITG)
    Yes. If this still creates issues move the Wisej.onLoad inside the first setTimeout.
  • Ivan Borges
    Brilliant. Thank you!
  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.