Skip to content

Instantly share code, notes, and snippets.

@ninegrid
Created March 16, 2014 09:27
Show Gist options
  • Save ninegrid/9580650 to your computer and use it in GitHub Desktop.
Save ninegrid/9580650 to your computer and use it in GitHub Desktop.
An editable area... markdown is rendered normally... double tap with your finger and viola a text area to edit it
{{#if isEditing}}
{{textarea value=value focus-out='doneEditing'}}
{{else}}
<a style="cursor:pointer">{{format-markdown value}}</a>
{{/if}}
export default Ember.Component.extend({
isEditing: false,
doubleClick: function() {
var element = this.$();
var h = element.height();
if (this.toggleProperty('isEditing')) {
Ember.run.next(this, function() {
this.$('textarea').focus();
this.$('textarea').addClass('focus');
this.$('textarea').height(h);
});
}
this.sendAction('editing');
},
actions: {
doneEditing: function() {
this.set('isEditing', false);
this.sendAction('action');
}
}
});
{{editable-area editing="edit" action="acceptChanges" value=bio}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment