I generate 2 templates dynamically using Blaze.renderWithData.
Data is different each time.
contactForm.each(function(index) {
const parent = $(selector).get(index);
const data = {email: parent.dataset.email}; // here data are different
Blaze.renderWithData(Template.contact, data, parent);
});
When I log data in the templates’ onCreated function, the data is different. But in onRendered, the first template data is in fact replaced by the second template data.
Why is that ?
Template.contact.onCreated(function() {
console.log('onCreated', this.data.email);
});
Template.contact.onRendered(function() {
console.log('OnRendered', this.data.email);
});
Results:
onCreated 1
onCreated 2
onCreated 3
OnRendered 3
OnRendered 3
OnRendered 3