From ba26eadd7ecb67f73f7d54ed4bcd928317ac1124 Mon Sep 17 00:00:00 2001 From: Keivan Beigi Date: Tue, 18 Jun 2013 18:10:32 -0700 Subject: [PATCH] ModelBoundView now blows up if there is no model. --- UI/Mixins/AsModelBoundView.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/UI/Mixins/AsModelBoundView.js b/UI/Mixins/AsModelBoundView.js index 13814b14a..7d1c961f7 100644 --- a/UI/Mixins/AsModelBoundView.js +++ b/UI/Mixins/AsModelBoundView.js @@ -10,10 +10,17 @@ define( originalBeforeClose = this.prototype.onBeforeClose; this.prototype.onRender = function () { - if (this.model) { - this._modelBinder = new ModelBinder(); - this._modelBinder.bind(this.model, this.el); + + if (!this.model) { + throw 'View has no model for binding'; } + + if (!this._modelBinder) { + this._modelBinder = new ModelBinder(); + } + + this._modelBinder.bind(this.model, this.el); + if (originalOnRender) { originalOnRender.call(this); }