HTML/JavaScript Snippet

0
This widget is not much reliable as it is difficult to predict when code placed inside this would work or when it would not. Say suppose i want to execute the code inside this snippet only after the data is loaded from data view . How do i make sure to this only after all the data is loaded? Is there a way to debug the code placed inside this?
asked
4 answers
2

Hi Vinutha,

Widgets are reliable and better than javascript snippets.

Have a look at the tutorial  and documentation to have a better understanding of the lifecyle of both Custom(Dojo) and Pluggable (React) widgets. Though I must admit, this is not the easiest subject and not so well documented

Cheers, Andries

 

answered
0

 

 

The document.ready() should be enough for running scripts right after dom loads. For debugging the normal debugger statement should work with any browser web inspector.

answered
0

Have you looked at building your own widget?

Custom widgets use Dojo and you act on events at different stages of the page lifecycle. In this case, it sounds like “startup” maybe the event you need. Have a look at the Dijit lifecycle documentation for more information. 
https://dojotoolkit.org/reference-guide/1.10/dijit/_WidgetBase.html

Pluggable widgets use React, but I’m afraid I’m not familiar enough with it to help here.

answered
0

There is a client api available for what you want

mx.addOnLoad(function() {
    console.log("You can use client functionality now");
});

You can find the documentation here: https://apidocs.rnd.mendix.com/8/client/mx.html

answered