我注意到不同浏览器中Meteor事件监听器的不一致。我可以在Chrome上监听儿童模板中触发的事件,但这不适用于Firefox和Safari(可能还有IE,呃)。
这是最小的复制代码:
Template.thisIsTheParent.events({
'click .a-class-that-lives-in-children': function(e, t) {
// Do something
}
});
Template.thisIsAChildBetweenOthers.events({
// On FF/Safari, I must put an event listener here on each children,
// that leads to massive code duplication.
'click .a-class-that-lives-in-children': function(e, t) {
// Do something that the parent should do :/
}
});
空格键(使用yield
模板由铁路由器处理):
<template name="thisIsTheParent">
<div>
{{ > yield }}
</div>
</template>
<template name="thisIsAChildBetweenOthers">
<a class="a-class-that-lives-in-children">I want to handle the click on that in the parent</a>
</template>
在Chrome上,会调用第一个事件侦听器,但不会在其他浏览器中调用。这是预期的行为吗?