For aplications who use framework-cli with webpacks, i dont find any methods to help me in this issue, so i using a trick do to this. The next code its declared in .html pages with templates tags
export default {
data: function() {
var self = this;
setInterval(function() {
self.$setState({
array_estoque: self.$root.array_estoque,
array_estoque_proprio: self.$root.array_estoque_proprio,
});
},0);
return {
array_estoque: self.$root.array_estoque,
array_estoque_proprio: self.$root.array_estoque_proprio,
}
},
methods: {
}
};
i dont find in documentation anything to refresh data declared in template, after view was create and the user visits for the second time the same page without call any method to force to do this.
this function recognizes new values
data: function() {
return {
value : firstValue,
}
},
methods: {
showGauge: function () {
this.$setState({
value : newValue;
})
},
}
can i call this method out of this template?
yes, i do this saving the this of template when the pageBeforeIn execute for the first time. Then when i call the function out of the template, i can access the method who call the setState method to reload data on template, below my code with that:
template in:
on: {
pageBeforeIn: function(e, page) {
var self = this;
app.f7.data[self.$route.url] = self;
}
},
methods: {
reload: function(nome) {
var self = app.f7.data[nome].$app.data;
app.f7.data[nome].$setState({
array_estoque: self.array_estoque,
array_estoque_proprio: self.array_estoque_proprio,
caminhoFoto: self.pasta_cdn+self.tipoAtual+self.edicao+’/’+self.dados.numpagina+’.jpg’,
ctrl_conjunto: self.dados.ctrl_conjunto
});
}
}
template out:
util.reloadTemplate(self.$app.views, ‘grades’);
util.js with the reloadTemplate function:
reloadTemplate: function(array, nome) {
array.filter(function(e) {
if (e.selector == ‘#view-’+nome) {
return e;
}
})[0].routes.filter(function(e) {
if (e.path == ‘/’+nome+’/’) {
return e;
}
})[0].component.methods.reload(’/’+nome+’/’)
}
};
export default util;