added avatar error correction on core view rendering
This commit is contained in:
parent
32ca5cc16d
commit
5d3145bf8f
2 changed files with 11 additions and 10 deletions
|
|
@ -46,6 +46,10 @@ app.views.Base = Backbone.View.extend({
|
||||||
this.$el
|
this.$el
|
||||||
.html(this.template(presenter))
|
.html(this.template(presenter))
|
||||||
.attr("data-template", _.last(this.templateName.split("/")));
|
.attr("data-template", _.last(this.templateName.split("/")));
|
||||||
|
|
||||||
|
// add avatar fallback if it can't be loaded
|
||||||
|
this.$el.find(this.avatars.selector).error(this.avatars.fallback);
|
||||||
|
|
||||||
this.postRenderTemplate();
|
this.postRenderTemplate();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -136,6 +140,13 @@ app.views.Base = Backbone.View.extend({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
avatars: {
|
||||||
|
fallback: function(evt) {
|
||||||
|
$(this).attr("src", ImagePaths.get("user/default.png"));
|
||||||
|
},
|
||||||
|
selector: "img.avatar"
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.views.StaticContentView = app.views.Base.extend({
|
app.views.StaticContentView = app.views.Base.extend({
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,6 @@ var View = {
|
||||||
.on('click', this.dropdowns.selector, this.dropdowns.click)
|
.on('click', this.dropdowns.selector, this.dropdowns.click)
|
||||||
.on('keypress', this.dropdowns.selector, this.dropdowns.click);
|
.on('keypress', this.dropdowns.selector, this.dropdowns.click);
|
||||||
|
|
||||||
/* Avatars */
|
|
||||||
$(this.avatars.selector).error(this.avatars.fallback);
|
|
||||||
|
|
||||||
/* Clear forms after successful submit, this is some legacy dan hanson stuff, do we still want it? */
|
/* Clear forms after successful submit, this is some legacy dan hanson stuff, do we still want it? */
|
||||||
$.fn.clearForm = function() {
|
$.fn.clearForm = function() {
|
||||||
return this.each(function() {
|
return this.each(function() {
|
||||||
|
|
@ -107,13 +104,6 @@ var View = {
|
||||||
},
|
},
|
||||||
selector: ".dropdown > .toggle",
|
selector: ".dropdown > .toggle",
|
||||||
parentSelector: ".dropdown > .wrapper"
|
parentSelector: ".dropdown > .wrapper"
|
||||||
},
|
|
||||||
|
|
||||||
avatars: {
|
|
||||||
fallback: function(evt) {
|
|
||||||
$(this).attr("src", ImagePaths.get("user/default.png"));
|
|
||||||
},
|
|
||||||
selector: "img.avatar"
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue