Created
July 29, 2013 21:09
-
-
Save marcioj/6107863 to your computer and use it in GitHub Desktop.
Integration of Tinymce with emberjs
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.TinymceView = Ember.TextArea.extend({ | |
editor: null, | |
_suspendValueChange: false, | |
didInsertElement: function(){ | |
var id = "#" + this.get("elementId"); | |
var view = this; | |
tinymce.init({ | |
selector: id, | |
setup : function(ed) { | |
view.set("editor", ed); | |
ed.on("keyup change", function() { | |
view.suspendValueChange(function() { | |
view.set("value", ed.getContent()); | |
}); | |
}); | |
} | |
}); | |
}, | |
suspendValueChange: function(cb) { | |
this._suspendValueChange = true; | |
cb(); | |
this._suspendValueChange = false; | |
}, | |
valueChanged: function() { | |
if (this._suspendValueChange) { return; } | |
var content = this.get("value"); | |
this.get("editor").setContent(content); | |
}.observes("value"), | |
willClearRender: function() { | |
this.get("editor").remove(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment