Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
ember: clicking html elements
EmberCloneMail.EmailListView = Em.View.extend({
tagName: "ul",
classNames: ["email-list", "email-view"],
templateName: "email-list-view"
});
EmberCloneMail.EmailPreview = Em.View.extend({
tagName: "li"
templateName: "email-preview"
});
<script data-template-name="email-list-view" type="text/x-handlebars">
{{#each EmberCloneMail.emailListController}}
{{view EmberCloneMail.EmailPreview contentBinding="this"}}
{{/each}}
</script>
<script data-template-name="email-preview" type="text/x-handlebars">
{{#with content}}
<span class="from">{{from}}</span>
<span class="subject">{{subject}}</span>
<span class="date">{{date}}</span>
{{/with}}
</script>
EmberCloneMail.EmailPreview = Em.View.extend({
tagName: "li"
templateName: "email-preview",
click: function(e){
// handle the view click here
}
});
<script data-template-name="email-preview" type="text/x-handlebars">
{{#with content}}
<span class="from" {{action "doStuff" on="click"}}>{{from}}</span>
<span class="subject">{{subject}}</span>
<span class="date">{{date}}</span>
{{/with}}
</script>
EmberCloneMail.EmailPreview = Em.View.extend({
tagName: "li"
templateName: "email-preview",
doStuff: function(){
// do stuff here, based on the click of the HTML element
}
});
EmberCloneMail.EmailPreview = Em.View.extend(Ember.TargetActionSupport, {
// tag, template, etc here
});
<script data-template-name="email-list-view" type="text/x-handlebars">
{{#each EmberCloneMail.emailListController}}
{{view EmberCloneMail.EmailPreview contentBinding="this"
target="EmberCloneMail.emailController"
action="showEmail"
}}
{{/each}}
</script>
<script data-template-name="email-preview" type="text/x-handlebars">
{{#with content}}
<span class="from">{{from}}</span>
<span class="subject">{{subject}}</span>
<span class="date">{{date}}</span>
{{/with}}
</script>
EmberCloneMail.EmailPreview = Em.View.extend(Ember.TargetActionSupport, {
// tag, template, etc her
click: function(e){
// call the targeted controller / action
this.triggerAction();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.