Skip to content

Instantly share code, notes, and snippets.

@lennym
Created January 29, 2014 12:03
Show Gist options
  • Save lennym/8686578 to your computer and use it in GitHub Desktop.
Save lennym/8686578 to your computer and use it in GitHub Desktop.
Ractive.JS ideas
var user = {
name: 'Mike',
points: 1
};
var ractive1 = new Ractive({
el: 'container',
template: '#template',
data: user
});
var ractive2 = new Ractive({
el: 'anothercontainer',
template: '#anothertemplate',
data: user
});
user.points = 1;
/** THOUGHTS **
* Would this update both elements, or do I need to ractive1.set(...); ractive2.set(...)?
* Assuming the answer to the above is no, is there any way I can have all views/templates
that depend on a data object update without having to call them all individually?
*/
@Rich-Harris
Copy link

@lennym - came across this via the Twitter conversation (I was CC'd at one point, or at least my alter ego @ractivejs was).

As @mikemaccana noticed, user.points = 2 didn't work. It does now, in the latest development builds. 'Magic mode' is really just another adaptor - if you had several Ractive views that shared a (for example) Backbone model, you could synchronise them all by using the Backbone adaptor, if you wanted to use that (plus the other features of Backbone models) rather than POJOs and ES5 magic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment