Skip to content

Instantly share code, notes, and snippets.

@deavial
Forked from sebmarkbage/InlineEditing.js
Created July 25, 2018 04:52
Show Gist options
  • Save deavial/16a9ec52196df5bfb170bb446e26c54c to your computer and use it in GitHub Desktop.
Save deavial/16a9ec52196df5bfb170bb446e26c54c to your computer and use it in GitHub Desktop.
el.set('contentEditable', true)
.addEvents({
keydown: function(e){ if (e.key == 'enter') e.preventDefault(); },
keypress: function(e){ if (e.event.which == 0 && e.code == 13) e.preventDefault(); },
blur: function(){ var text = this.get('text'); this.set('text', text); }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment