Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

Can anyone comment on using Ractive as a replacement to Backbone.View? I'd think that making Ractive the view layer in a Backbone app would go a long way in augmenting a lot of the things that Backbone refuses to do in views (binding, smart DOM management/manipulation, actual templating support)


There's a Ractive.extend() function for this exact use case, which allows you to incorporate all the functionality your Backbone View would have in a reusable constructor. Info on the wiki: https://github.com/Rich-Harris/Ractive/wiki/Ractive.extend()

There's also a concept of 'adaptors' which are ideal for Backbone.Model <-> Ractive binding, though it's a bit experimental and incomplete at the moment. You can bind to a model manually like

model = new MyBackboneModel( attrs ); ractive = new Ractive({ el: whatever, template: tpl, data: model.attributes });

model.on( 'change', function ( model ) { ractive.set( model.changed ); });




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: