mirror of
https://github.com/Radarr/Radarr
synced 2024-12-27 02:09:59 +00:00
much smarter binding,
auto-binding is only done when the element has binding attributes ('name') also now an error is throw in there are binding elements but view doesn't have a model
This commit is contained in:
parent
acb15d8e49
commit
979efb8354
3 changed files with 17 additions and 7 deletions
|
@ -13,7 +13,6 @@ Marionette.TemplateCache.get = function (templateId) {
|
||||||
return function (data) {
|
return function (data) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//console.log('rendering template ' + templateKey);
|
|
||||||
return templateFunction(data);
|
return templateFunction(data);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ Marionette.View.prototype.viewName = function () {
|
||||||
|
|
||||||
return this.template
|
return this.template
|
||||||
.toLocaleLowerCase()
|
.toLocaleLowerCase()
|
||||||
.replace('template','')
|
.replace('template', '')
|
||||||
.replace(regex, '-');
|
.replace(regex, '-');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,12 +21,25 @@ Marionette.ItemView.prototype.render = function () {
|
||||||
|
|
||||||
var result = oldItemViewRender.apply(this, arguments);
|
var result = oldItemViewRender.apply(this, arguments);
|
||||||
|
|
||||||
this.$el.addClass('iv-' + this.viewName());
|
|
||||||
|
|
||||||
if (this.model) {
|
|
||||||
NzbDrone.ModelBinder.bind(this.model, this.el);
|
//check to see if el has bindings (name attribute)
|
||||||
|
// any element that has a name attribute and isn't child of another view.
|
||||||
|
if (this.$('[name]').not("[class*='iv-'] [name]").length > 0) {
|
||||||
|
if (!this.model) {
|
||||||
|
throw 'view ' + this.viewName() + ' has binding attributes but model is not defined';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this._modelBinder) {
|
||||||
|
this._modelBinder = new Backbone.ModelBinder();
|
||||||
|
}
|
||||||
|
|
||||||
|
window.console.log('binding ' + this.viewName());
|
||||||
|
|
||||||
|
this._modelBinder.bind(this.model, this.el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.$el.addClass('iv-' + this.viewName());
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,6 @@ define('app', function () {
|
||||||
|
|
||||||
console.log('starting application');
|
console.log('starting application');
|
||||||
|
|
||||||
NzbDrone.ModelBinder = new Backbone.ModelBinder();
|
|
||||||
|
|
||||||
//TODO: move this out of here
|
//TODO: move this out of here
|
||||||
Handlebars.registerHelper("formatStatus", function (status, monitored) {
|
Handlebars.registerHelper("formatStatus", function (status, monitored) {
|
||||||
if (!monitored) {
|
if (!monitored) {
|
||||||
|
|
Loading…
Reference in a new issue