I have a bootstrap modal that will display info about a parent document. The modal then has next/prev
buttons that can rotate around a list of parent documents and reactively change the info displayed on the modal. It does this by simply changing a ReactiveVar of the current parent’s onClick of next/prev. This works like a charm.
My problem is that each parent shows some child data as well. The child data is an array of embedded documents. And each document’s property has some HTML inputs. I’m trying to pre-populate the values of the html inputs. However, I’m finding this does not work. id
and foo
are properties on the child document(s).
A call to {{parent}} is a Helper
method that returns the current parent
from MiniMongo. This seems to work fine as the parent’s metadata changes reactively.
<div> Parent Name {{parent.Name}} </div>
{{#each parent.childrenArray}}
<input type="text" id="{{id}}" value="{{foo}}">
{{/each}}
Here’s my helper on how to retrieve the Reactive Parent
parent: function () {
//ReactiveVar Object that changes based on next/prev clicks (this works)
const parentId = Template.instance().currentParentId.get();
var parent = Parents.findOne({ _id: parentId});
return parent;
},
So the issue is that the HTML value does not change. Clicking next
will still show the old child’s value. I understand there’s no reactivity for embedded documents and I’m sure this is the problem. Strangely, upon inspecting, I am in fact seeing the input's
id
being changed though. Does anybody know the solution to this? Thanks!