Firefox只有jQuery的错误 - handleObj.handler.apply不是一个函数 [英] Firefox only error with jQuery - handleObj.handler.apply is not a function

查看:455
本文介绍了Firefox只有jQuery的错误 - handleObj.handler.apply不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个扩展Dan Grossman的range picker的插件。 这是我的回购。请原谅我乱七八糟的代码,这仍然是一个正在进行的工作。我的问题是,Firefox不能识别点击输入。 这是相关的行:

  this.container.find('。ranges')
.on('click',
'.daterangepicker_start_input,。 daterangepicker_end_input',
$ .proxy(this.focusInput,this));

现在函数 focusInput 本身不会事实上,因为我在它的顶部添加了一个简单的 console.log ,这非常明显,它根本没有被运行(添加断点也没有帮助)。

我以为这可能是因为我使用禁用的输入,但改变没有帮助(这不应该是一个问题,因为事件)

我从Firefox控制台得到的错误信息是:

$ $ p $类型错误:handleObj.handler.apply不是一个函数jquery-1.11.0.js:4995
TypeError:handleObj.handler.apply不是一个函数jquery-1.11.0.js :4624

这告诉我这个问题是与jQuery(我觉得很难相信)。我猜我做了错误的事情,导致与jQuery的错误,但作为Chrome不抱怨,我很难追查到哪里我错了。



我很乐意在这方面得到一些帮助。提前致谢!

更新

我已经更新了github中的代码。现在,点击不能只与最初隐藏的元素(这是没有意义的),但更重要的是 - 我没有得到任何错误。所以我卡住了我不知道什么是FF的问题。即使Internet Explorer不抱怨 - 到底是什么?

解决方案

?委托的目的是定位一个你知道永远存在并且可见的元素,然后从那里委派一些元素,这些元素可以在这个脚本的整个生命周期中出现。



试试这个:

$ $ p $ this.container.on('click',
'.ranges .daterangepicker_start_input,。范围.daterangepicker_end_input',
$ .proxy(this.focusInput,this));

更新:



  $('。target')。on ('click','.thing',$ .proxy(this.doStuff),this); 

如果我移动的话) $($。$ $ $ $ $ $'$'$'$'$'''。')。

你有类似的事情吗?你粘贴的代码应该没问题。 我做了一个jsFiddle来尝试隔离问题。


I'm working on a plugin that expands Dan Grossman's rangepicker. Here's my repo. Please forgive my messy code, this is still a work in progress. My problem is that Firefox doesn't recognize clicking on the inputs. This is the relevant line:

this.container.find('.ranges')
    .on('click', 
        '.daterangepicker_start_input, .daterangepicker_end_input',   
        $.proxy(this.focusInput, this));

Now the function focusInput itself doens't matter, really, because I added a simple console.log at the top of it and it's very obvious it isn't being run at all (adding breakpoints didn't help either).

I thought it might be because I'm using disabled inputs, but changing that didn't help (and it shouldn't be a problem, as the event is caught through the parent element).

The error message I get from the Firefox console is:

TypeError: handleObj.handler.apply is not a function       jquery-1.11.0.js:4995
TypeError: handleObj.handler.apply is not a function       jquery-1.11.0.js:4624

Which tells me the issue is with jQuery (which I find hard to believe). I'm guessing I did something wrong that causes an error with jQuery, but as Chrome doesn't complain, I have a hard time tracing where exactly I went wrong.

I'd love to get some help on this. Thanks in advance!

update

I've updated the code in github. Now the clicking is not working only with elements that were hidden at first (which uh... doesn't make sense), but more importantly - I'm not getting any errors at all. So I'm stuck. I have no idea what's FF's problem. Even Internet Explorer isn't complaining - what the hell??

解决方案

Are any ranges available at the time when they are delegated to? The point of delegation is to target an element that you know will always exist and be visible, then delegate from there to elements that may come and go throughout the life of the script.

Try this:

this.container.on('click',
    '.ranges .daterangepicker_start_input, .ranges .daterangepicker_end_input',
    $.proxy(this.focusInput, this));

UPDATE:

I can reproduce this issue if I make a syntax error like so:

$('.target').on('click', '.thing', $.proxy(this.doStuff), this);

If I move the ) then it works as intended.

$('.target').on('click', '.thing', $.proxy(this.doStuff, this));

Do you have something similar happening? The code as you pasted it should be fine. I made a jsFiddle to try and isolate the issue.

这篇关于Firefox只有jQuery的错误 - handleObj.handler.apply不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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