Using Backbone, Marionette (1.8.3), StickIt and TypeScript. How could I bind the lenght of a Backobone collection so that it gets update whenever items are added to or removed from the collection?
I'm quite new to StickIt and here what I have tried so far
export class SomeView extends marionette.CompositeView<backbone.Model, SomeItemView> {
(...)
bindings = {
"[data-bind-observer=count]": {
observe: ["collection.length"],
onGet: (collection) => {
return collection.length;
}
}
};
}
If you are using Backbone 1.3.3, it's better to listen to the collection's update event. But I am assuming you have to use an old version of Backbone because of work, so I'll give you a relevant answer
If you can, try upgrading to Backbone 1.3.3 or Marionette 3.