Jabran Saeed
Jabran Saeed

Reputation: 6168

RactiveJS bind multiple objects to template

Is it possible to bind more than one data object to a template? I find the single object philosophy a bit resistant to scalability. How can I add more observant data objects to a template without modifying the one already attached to it.

Upvotes: 0

Views: 41

Answers (1)

PEtter
PEtter

Reputation: 836

When you instanciate the ractive instance you could do something like this.

var r = new Ractive({data : {Object1:{},
                             Object2:{} } });

Then you can attached as many objects as you want.

Then you can scope this in your templates by doing

{{#Object1}}
<div>{{Prop1}}
{{/Obj1}}

{{#Object2}}
<div>{{PropForObject2}}
{{/Obj2}}

Upvotes: 1

Related Questions