Pass the post to any events bound to custom names

This commit is contained in:
Robin Ward 2014-05-14 15:21:11 -04:00
parent 3211c60bbe
commit 93b2af8a6e

View file

@ -37,19 +37,21 @@ var PosterNameComponent = Em.Component.extend({
if (Em.isEmpty(primaryGroupName)) { if (Em.isEmpty(primaryGroupName)) {
buffer.push(title); buffer.push(title);
} else { } else {
buffer.push("<a href='#' class='user-group'>" + title + "</a>"); buffer.push("<a href='/groups/" + post.get('primary_group_name') + "' class='user-group'>" + title + "</a>");
} }
buffer.push("</span>"); buffer.push("</span>");
} }
PosterNameComponent.trigger('renderedName', buffer); PosterNameComponent.trigger('renderedName', buffer, post);
} }
}, },
click: function(e) { click: function(e) {
var $target = $(e.target); var $target = $(e.target),
if ($target.hasClass('user-group')) { href = $target.attr('href');
Discourse.URL.routeTo("/groups/" + this.get('post.primary_group_name'));
if (!Em.isEmpty(href) && href !== '#') {
return true;
} else { } else {
this.sendAction('expandAction', this.get('post')); this.sendAction('expandAction', this.get('post'));
} }