Last active
August 29, 2015 14:01
-
-
Save turboMaCk/ecb6f337ceec2818a37d to your computer and use it in GitHub Desktop.
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
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') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example use: