Skip to content

Instantly share code, notes, and snippets.

@gunn
Created August 22, 2014 11:06
Show Gist options
  • Save gunn/3bf7abd03e52dd6088b6 to your computer and use it in GitHub Desktop.
Save gunn/3bf7abd03e52dd6088b6 to your computer and use it in GitHub Desktop.
Component action forwarding
App.ApplicationRoute = Em.Route.extend({
actions: {
open: function(tweet) {
var handle, url;
handle = tweet.account.screen_name;
url = "https://twitter.com/" + handle + "/status/" + tweet.tweet_id;
return window.open(url, '_blank');
}
}
});
{{ tweet-panel
tweets=view.selectedTweets
click="open" }}
<div id="panel">
{{#each tweets}}
<div class="tweet" {{action "click" this allowedKeys="any"}}>
<p>{{text}}</p>
<span class="retweet-count">{{retweet_count}}</span>
<span class="favorite-count">{{favorite_count}}</span>
<span class="date">{{formatDate date}}</span>
<div class="account">– {{account.name}} (@{{account.screen_name}})</div>
</div>
{{/each}}
</div>
App.TweetPanelComponent = Ember.Component.extend({
actions: {
click: function(tweet) {
return this.sendAction("click", tweet);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment