-
-
Save mxriverlynn/1880628 to your computer and use it in GitHub Desktop.
ember: clicking html elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EmberCloneMail.EmailPreview = Em.View.extend({ | |
tagName: "li" | |
templateName: "email-preview", | |
click: function(e){ | |
// handle the view click here | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EmberCloneMail.EmailPreview = Em.View.extend({ | |
tagName: "li" | |
templateName: "email-preview", | |
doStuff: function(){ | |
// do stuff here, based on the click of the HTML element | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EmberCloneMail.EmailPreview = Em.View.extend(Ember.TargetActionSupport, { | |
// tag, template, etc here | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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