如何在Meteor JS中检测整个文档上的事件? [英] How to detect events on entire document in Meteor JS?
问题描述
就这么简单.我目前在模板事件中,但是无法正常工作:
It's really as simple as that. I currently have in my template events, but it is not working:
'keyup': function(event) {
event.preventDefault();
console.log("KEYUP");
}
更新:它似乎是框架中的一般错误.如果有人可以分享我可以采用的手动技巧,而无需使用别人的软件包,我将不胜感激.
Update: it appears to be a generic bug in the framework. I would appreciate it if anyone could share a manual hack I could employ that doesn't involve using someone else's packages.
更新2:我已经解决了这个问题,如下所示.
Update 2: I have solved this problem as shown below.
推荐答案
我的原始代码突然起作用了.也许流星的好人已经解决了这个问题,是的!
All of a sudden my original code works. Maybe the good folks at Meteor has fixed the problem, yay!
在0.9.3.1上,这对我有用:
Here's what works for me on 0.9.3.1:
Template.template_name_here.events({
'keyup': function(event) {
event.preventDefault();
console.log("KEYUP");
}
});
流星甚至可以使用单个处理程序来处理多个事件,如下所示:
Meteor can even handle multiple events with a single handler like this:
Template.template_name_here.events({
'keyup, click': function(event) {
event.preventDefault();
console.log("KEYUP OR CLICK");
}
});
太棒了!
这篇关于如何在Meteor JS中检测整个文档上的事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!