Add some safety when rendering a dropdown button to make sure it has

content.
This commit is contained in:
Robin Ward 2015-01-15 15:43:20 -05:00
parent 4a11bb5227
commit e4e239c159
1 changed files with 16 additions and 13 deletions

View File

@ -31,20 +31,23 @@ export default Discourse.View.extend(StringBuffer, {
buffer.push("</button>");
buffer.push("<ul class='dropdown-menu'>");
var self = this;
this.get('dropDownContent').forEach(function(row) {
var id = row.id,
title = row.title,
iconClass = row.styleClasses,
description = row.description,
className = (self.get('activeItem') === id ? 'disabled': '');
var contents = this.get('dropDownContent');
if (contents) {
var self = this;
contents.forEach(function(row) {
var id = row.id,
title = row.title,
iconClass = row.styleClasses,
description = row.description,
className = (self.get('activeItem') === id ? 'disabled': '');
buffer.push("<li data-id=\"" + id + "\" class=\"" + className + "\"><a href>");
buffer.push("<span class='icon " + iconClass + "'></span>");
buffer.push("<div><span class='title'>" + title + "</span>");
buffer.push("<span>" + description + "</span></div>");
buffer.push("</a></li>");
});
buffer.push("<li data-id=\"" + id + "\" class=\"" + className + "\"><a href>");
buffer.push("<span class='icon " + iconClass + "'></span>");
buffer.push("<div><span class='title'>" + title + "</span>");
buffer.push("<span>" + description + "</span></div>");
buffer.push("</a></li>");
});
}
buffer.push("</ul>");