How to access a calculated field of a backbone model from handlebars template?

后端 未结 4 1722
遇见更好的自我
遇见更好的自我 2021-02-05 16:01

I would like to access the calculated fields I have implemented in the model (backbone.js) from the template. Do I need always to define a helper to do it?

I think the p

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-05 16:04

    Here is another possibility: (from the model initialize)

    initialize: function() {
            this.on("change", function () {
                this.set({ calculatedColumn: this.get("otherColumn") }, { silent: true });
            });
        },
    

    Computed properties in Backbone

提交回复
热议问题