mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-26 23:06:43 -04:00
Moved source code under src folder - massive change
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
define(
|
||||
['backbone.modelbinder'],
|
||||
function (ModelBinder) {
|
||||
|
||||
return function () {
|
||||
|
||||
var originalOnRender = this.prototype.onRender,
|
||||
originalBeforeClose = this.prototype.onBeforeClose;
|
||||
|
||||
this.prototype.onRender = function () {
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
this.prototype.beforeClose = function () {
|
||||
|
||||
if (this._modelBinder) {
|
||||
this._modelBinder.unbind();
|
||||
delete this._modelBinder;
|
||||
}
|
||||
|
||||
if (originalBeforeClose) {
|
||||
originalBeforeClose.call(this);
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user