如何在emberjs上的textarea上收听粘贴事件 [英] How to listen to a paste event on a textarea in emberjs
本文介绍了如何在emberjs上的textarea上收听粘贴事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含以下模板的组件:
I have a component that holds a with the following template:
<div>
{{textarea value=content autofocus="autofocus"}}
<button {{action 'cancel'}}>cancel</button>
</div>
如何收听粘贴
事件在我的组件中的这个textarea上?
How can I listen to a paste
event on this textarea in my component?
我试图倾听粘贴操作,但这似乎不起作用:
I tried to listen on the paste action but this dont seems to work:
App.EditableTextComponent = Ember.Component.extend({
templateName: 'components/editable-text',
actions: {
paste: function() {
console.log(arguments);
}
}
});
推荐答案
As @ wojciech-bednarski在他的评论中建议已将自定义事件侦听器添加到我的应用程序中:
As @wojciech-bednarski suggest in his comment, I have added the custom event listener to my app:
var App = Ember.Application.create({
customEvents: {
paste: "paste"
}
});
,然后可以在我的组件中收听
and could then listen to it in my component
App.EditableTextComponent = Ember.Component.extend({
paste: function(event) {
console.log(event)
}
});
这篇关于如何在emberjs上的textarea上收听粘贴事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文