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 | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 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) { + + if (!this.model) { + throw 'View has no model for binding'; + } + + if (!this._modelBinder) { this._modelBinder = new ModelBinder(); - this._modelBinder.bind(this.model, this.el); } + + this._modelBinder.bind(this.model, this.el); + if (originalOnRender) { originalOnRender.call(this); }