Template.data doesn't update until user clicks on template


#1

Template.data is not updated with the latest information from the server until that template is clicked on.

I have an item template that can have other item templates. The data for that template looks like this:

{
    _id: 'item1',
    title: 'item1',
    children: ['item2'] // it has a child item template
}

I save a reference to that template in

theTemplateInstance

and call a method to remove the child from the item1 in the server.

Items.update({children: 'item2'}, {$pull:{children: 'item2'}}, {multi: true} );

Calling:

console.log(theTemplateInstance.data.children)

shows the wrong output:

// wrong output:  ['item2']
// it should be empty like this: []

shows the children array not updated, even though the minimongo value is correct.

Now if I click on the template and log again the children array is now empty (the correct value).

Any idea on what could be wrong? Why isn’t the data updating before interaction?

This is driving me crazy!

Any kind of help would be greatly appreciated!