javascript - BackBone Model - > Collection -> Model -> Update - does not trigger change on root model -
i'm having this
serverinfomodel = backbone.relationalmodel.extend({ relations: [ { type: backbone.hasmany, key: 'data', relatedmodel: 'data', collectiontype: 'datacollection', reverserelation: { key: 'id', includeinjson: 'id' } } ] }) data = backbone.relationalmodel.extend({ }); datacollection = backbone.collection.extend({ model: data });
now have view associated serverinfomodel. if change value model data within collection, "change" not triggered on serverinfomodel, triggered on datacollection;
how can pass "change" event serverinfomodel datacollection ?
i found out how it, listen 'data' change , trigger 'change' futher
serverinfomodel = backbone.baserelationalmodel.extend({ url: function () { return "/examples/serverinfo.json" }, setup: function () { var self= this; this.get('data').on('change', function () { self.trigger("change"); }); }, relations: [ { type: backbone.hasmany, key: 'data', relatedmodel: 'data', collectiontype: 'datacollection', reverserelation: { key: 'id', includeinjson: 'id' } } ] }); data = backbone.baserelationalmodel.extend({ }); datacollection = backbone.collection.extend({ model: data });
Comments
Post a Comment