Skip to content

Instantly share code, notes, and snippets.

@cloke
Created April 1, 2012 22:16
Show Gist options
  • Save cloke/2279116 to your computer and use it in GitHub Desktop.
Save cloke/2279116 to your computer and use it in GitHub Desktop.
Custom view
M.Paragraph = Em.View.extend(Ember.TextSupport, {
viewName: 'paragraph_view',
content: null,
attributeBindings: ['text'],
text: '',
editable: false,
_editable: (function() {
console.log(arguments);
return this.set('editable', Em.getPath(arguments[1]));
}).observes('M.editable.status'),
template: Ember.Handlebars.compile('{{#if this.editable}}\
<div contentEditable="true">{{content.text}}</div>\
{{view Em.TextArea valueBinding="content.text"}}\
{{else}}\
<p>{{content.text}}</p>\
{{/if}}'),
change: function() {
return console.log(5);
},
keyup: function() {
return console.log(7);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment