In the solution I’ve been asked to maintain, there are several responsive SVG charts. When the page is loaded, settings for each chart are stored using the following:
<input type='text' id='chartA' style='display:none' value='{{settingsChartA}}'>
Then, when the window is resized, there is no current view so the data SVG data are loaded from this value:
if (Blaze.currentView && Template.currentData()) {
let currentData = Template.currentData();
if (currentData) {
settings = ....
}
} else { //WHEN THERE IS NO VIEW, USED STORED DATA
let s = $('#chartA').val();
if (s) {
settings = JSON.parse(s);
}
}
return settings;
I’m now wondering, why not use a global variable, isnt it much simpler? It would be set and read the same way as the input field above. Am I missing some obvious drawback / issues?