Polymer elements have .set and array manipulation methods, but using those you can't really separate your logic from presentation. Backbone is pretty good for framework-agnostic logic, and its event mechanism provides the same type of notifications that Polymer needs to render dynamically.
So backbone-polymer aims to let Polymer templates, data binding and dom-repeat, use Collections of Models as properties.
Registers event listeners on backbone and calls notifyPath on an element.
We require the lib with Webpack and do yobo mixins, but any call with the Collection as this is fine.
var c = new Backbone.Collection();
BackbonePolymerAttach.call(c, myPolymerElement, 'theCollectionPropertyName');See the test folder for real examples.
- Only collection's
.adddoes notify, so for.removeyou need to re-render your dom-repeat. - Can't
.addimmediately after attaching the collection to Polymer (your added items will render as empty), so add right before or asynchronously after. - Tests pass only in Chrome so other browsers may be supported