Skip to content

Instantly share code, notes, and snippets.

@turboMaCk
Last active August 29, 2015 14:01
Show Gist options
  • Save turboMaCk/ecb6f337ceec2818a37d to your computer and use it in GitHub Desktop.
Save turboMaCk/ecb6f337ceec2818a37d to your computer and use it in GitHub Desktop.
Ember.MediumEditor = Ember.View.extend({
editor: null,
initializeEditor: function() {
var self = this,
element = this.get('element');
this.valueObserver();
this.set('editor', new MediumEditor(element));
$(element).on('input', function(event) {
self.set('value', $(element).html());
});
}.on('didInsertElement'),
valueObserver: function() {
var $element = this.$(),
value = this.get('value');
if ($element.html() !== value) {
$element.html(value);
}
}.observes('value'),
destroyEditor: function() {
var element = this.get('element');
$(element).off('input');
}.on('willDestroyElement')
});
@turboMaCk
Copy link
Author

Example use:

{{view Ember.MediumEditor value=content.description classNames='form-control medium-editor' id='description'}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment