UI Cleanup - Updated Instrumentation, jQuery and Mixins subtrees.

This commit is contained in:
Taloth Saldono
2015-02-13 22:06:20 +01:00
parent 44928c8f64
commit 70bfad4e6a
24 changed files with 716 additions and 490 deletions
+23 -12
View File
@@ -1,35 +1,46 @@
var ModelBinder = require('backbone.modelbinder');
module.exports = function(){
module.exports = function() {
var originalOnRender = this.prototype.onRender;
var originalBeforeClose = this.prototype.onBeforeClose;
this.prototype.onRender = function(){
if(!this.model) {
this.prototype.onRender = function() {
if (!this.model) {
throw 'View has no model for binding';
}
if(!this._modelBinder) {
if (!this._modelBinder) {
this._modelBinder = new ModelBinder();
}
var options = {
changeTriggers : {
"" : 'change typeahead:selected typeahead:autocompleted',
"[contenteditable]" : 'blur',
"[data-onkeyup]" : 'keyup'
'' : 'change typeahead:selected typeahead:autocompleted',
'[contenteditable]' : 'blur',
'[data-onkeyup]' : 'keyup'
}
};
this._modelBinder.bind(this.model, this.el, null, options);
if(originalOnRender) {
if (originalOnRender) {
originalOnRender.call(this);
}
};
this.prototype.onBeforeClose = function(){
if(this._modelBinder) {
this.prototype.onBeforeClose = function() {
if (this._modelBinder) {
this._modelBinder.unbind();
delete this._modelBinder;
}
if(originalBeforeClose) {
if (originalBeforeClose) {
originalBeforeClose.call(this);
}
};
return this;
};
};