added view name as class to DOM element for easier debugging.

This commit is contained in:
kay.one 2013-04-10 21:28:17 -07:00
parent 30595e85a3
commit 19dfd49ad3
1 changed files with 16 additions and 4 deletions

View File

@ -3,13 +3,27 @@
var oldItemViewRender = Marionette.ItemView.prototype.render; var oldItemViewRender = Marionette.ItemView.prototype.render;
var oldItemCollectionViewRender = Marionette.CollectionView.prototype.render; var oldItemCollectionViewRender = Marionette.CollectionView.prototype.render;
Marionette.View.prototype.viewName = function () {
if (this.template) {
var regex = new RegExp('\/', 'g');
return this.template
.toLocaleLowerCase()
.replace('template','')
.replace(regex, '-');
}
return undefined;
};
Marionette.ItemView.prototype.render = function () { Marionette.ItemView.prototype.render = function () {
if (this.model) { if (this.model) {
NzbDrone.ModelBinder.bind(this.model, this.el); NzbDrone.ModelBinder.bind(this.model, this.el);
} }
console.log("render"); this.$el.addClass('iv-' + this.viewName());
return oldItemViewRender.apply(this, arguments); return oldItemViewRender.apply(this, arguments);
}; };
@ -20,7 +34,5 @@ Marionette.CollectionView.prototype.render = function () {
NzbDrone.ModelBinder.bind(this.model, this.el); NzbDrone.ModelBinder.bind(this.model, this.el);
} }
console.log("render");
return oldItemCollectionViewRender.apply(this, arguments); return oldItemCollectionViewRender.apply(this, arguments);
}; };