没有为使用Firefox的Knockout点击绑定定义事件参数 [英] Event parameter not defined for Knockout click binding using Firefox

查看:89
本文介绍了没有为使用Firefox的Knockout点击绑定定义事件参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此JS错误: ReferenceError:事件未定义当我尝试将事件对象传递给使用Firefox 23时单击绑定时。一切正常在Chrome下

I am getting this JS error: ReferenceError: event is not defined when I try to pass the event object to click binding when I use Firefox 23. Everything works fine under Chrome

此处代码:

<!-- ko foreach: entries -->
   <tr data-bind="click: function(){ $parent.expandRow($data, event) }">
      ...
   </tr>
<!-- /ko -->


vm.entries.expandRow = function(entry, event){
    ...           
}


推荐答案

这里的解决方案来自 github.com/knockout/knockout/issues/752

<!-- ko foreach: entries -->
   <tr data-bind="click: function(data, event){ $parent.expandRow($data, event) }">
      ...
   </tr>
<!-- /ko -->

在Firefox下,事件没有在窗口对象上定义,而是需要传递给函数。

Under Firefox event is not defined on the window object, instead it needs to be passed to the function.

这篇关于没有为使用Firefox的Knockout点击绑定定义事件参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆