publish event when page has page problems

Hey Sam, that is a really good idea, we should publish events whenever there is an error so that you can deal with them either declaratively or with JavaScript, and so that you can handle them as they happen.

Right now, though, we don’t publish any such event.

However, there is a JavaScript API that you could call to get all page problems: skuid.page.getAllProblems()

So you could potentially call this API on a timer from JavaScript and then do what you’re saying. Add Inline JavaScript to the page like this:

(function(skuid){
   skuid.$(document.body).one(‘pageload’,function(){
         var problemsModel = skuid.$M(“ProblemsModel”);

        // Poll every 2 seconds to check for problems
        var INTERVAL_FREQUENCY_IN_SECONDS = 2;
        
        setInterval(function(){
           var problems = skuid.page.getAllProblems();
           // If we have net-new problems since we last checked,
           // wipe out our current problems model and replace its contents
           if (problems.length !== problemsModel.getRows().length) {
              problemsModel.emptyData();
              problemsModel.adoptRows(problems);
           }
        }, INTERVAL_FREQUENCY_IN_SECONDS * 1000);
   });
})(skuid);

This assumes that you have a Model called “ProblemsModel” in your page (e.g. a Ui-Only Model) that has a field in it whose id is “message”.