From d08b1c94bf96b2aaf99c7a64bb558073e16e45aa Mon Sep 17 00:00:00 2001 From: Reinier Guerra Date: Thu, 4 Jun 2015 15:12:12 -0400 Subject: [PATCH] Update backbone.getters.setters.js --- backbone.getters.setters.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/backbone.getters.setters.js b/backbone.getters.setters.js index f5ec2ba..a1fcc4e 100644 --- a/backbone.getters.setters.js +++ b/backbone.getters.setters.js @@ -34,6 +34,15 @@ Backbone.GSModel = Backbone.Model.extend({ return Backbone.Model.prototype.set.call(this, attrs, options); }, + toJSON : function () { + var gettersJSON = {}; + _.each(this.getters,function (getter,name) { + if (_.isFunction(getter)) { + gettersJSON[name] = getter.call(this); + } + }.bind(this)); + return _.extend(Backbone.Model.prototype.toJSON.apply(this,arguments),gettersJSON); + } getters: {},