I'm trying to get an Ember.View to listen to events triggered by a contenteditable element, but am having a little trouble.
The end result I'm going for is to have the contenteditable changes bound to an Ember Object property.
Events are correctly bound using jQuery directly as given in this answer: contenteditable change events
$(function () {
$(document).on('focus', '[contenteditable]', function(event) {
var $this = $(this);
console.log("$" + event.type);
return $this;
});
$(document).on('blur keyup paste', '[contenteditable]', function(event) {
var $this = $(this);
console.log("$" + event.type);
return $this;
});
});
But event handlers that specified on the Ember.View never get called:
App.ContentEditable = Ember.View.extend({
item: App.Item.create({name:"Editable content"}),
tagName: "span",
contenteditable:"true",
attributeBindings: ["contenteditable"],
// Only event that gets triggered
click: function(){ console.log("click") },
// None of these events are triggered
focusin: function(){ console.log("focusin") },
focusout: function(){ console.log("focusout") },
keyup: function(){ console.log("keyup") },
blur: function(){ console.log("blur") },
paste: function(){ console.log("paste") },
});
I've put together a jsfiddle showing that the .on()
events are logged to the console but the events on the Ember.View are not: http://jsfiddle.net/chrisconley/RqSn4/