In Dashboard v1, instead of using ui-table
I used to instantiate the Tabulator package directly inside ui-template
nodes (in order to leverage the full package capabilities).
When switching to dashboard 2, I noticed that sometimes Tabulator fails to load (with various error types) unless given some “breather” delay.
I tried to add a Vue component and piggyback its mounted()
callback for the Tabulator instantiation, but the issue persists.
I am currently solving this by placing the initialization within a timeout loop, but wonder if there is some other event or status I can wait for, which will allow me to avoid this loop. The code I’m using is:
var count = 0;
let interval = setInterval(() => {
try {
initGrid(); // Where I do the actual instantiation
clearInterval(interval);
} catch (err) {
count++;
if (count >= 30) { // abort after 3 seconds
console.log ("Grid load failed: "+err);
clearInterval(interval);
}
}
}, 100);
On another note, I noticed that when working with Vue components, I cannot place any general (not Vue-related) JavaScript code outside of Vue’s export default {...}
structure, and I need to place it in another JavaScript section.
What would be a better approach - to place all my code (Vue & non-Vue) within the Vue’s export default {...}
structure, or use separate script sections?