How to use widget's onError to display html
I wonder if it was possible to use a widget's onError
function to change the content of the error container to sopmething different than an triangle with exclamation mark.
I've tried
onError: function ($errorContainer, data, widgetId) {
$('.error', $errorContainer).html(data.error);
}
but it keeps on showing me just this triangle. Is this the right way to go or can I manage this on a different way?
Comments (2)
-
-
I have the same issue as described by @fjakob and it appears like the content is being overwritten before it could be displayed, when I use the
onError
callback. A simple workaround I've found is to usesetTimeout
with a delay of 0 (i. e., if will be executed immediately after the current event-queue has been processed) to replace the content of the error widget. Still, what is the use of having anonError
event handler in the widget file if not for displaying some custom error notification. I haven't yet tried @mkaruppasamy's approach but it makes me wonder why we have to got to such lengths instead of just fixing the onError callback, which intuitively, seems like the right place to customize the shown error widget. - Log in to comment
You can display the error message instead of
⚠
, by adding the below script in yourwidgets/WIDGET_NAME/WIDGET_NAME.js
file.You can also do apply the same for all the widgets in your project by creating a new
custom_error.js
file underassets/javascript
folder and invoke the same in your eachdashboard/*.json
file."customJS": ["custom_error.js"]