gpt4 book ai didi

javascript - 错误: Cannot read property 'blur' of undefined

转载 作者:行者123 更新时间:2023-12-03 08:07:44 24 4
gpt4 key购买 nike

我正在尝试实现 wheelColorPicker ,并且我在使用 1.7.1 之后的 JQuery 版本时遇到了问题。 (我目前使用的是 1.10.2。)

当我使用更高版本并移动任何 slider ,然后停止移动它(mouseUp)时,colorPicker 不会注册 mouseUp,因此会继续移动 slider (或拖动器)。当它移动时我也收到以下错误:

Uncaught TypeError: Cannot read property 'blur' of undefined

我认为我必须改变的主要事情是事件如何解除绑定(bind)。

var blurEvents = $input.data('events').blur;

不工作:

JSFiddle

工作中:

JSFiddle

(我无法让它使用带有代码片段的外部文件,并且问题对字符数有限制。这就是我没有包含代码片段的原因。)

最佳答案

$(element).data("events") 在 jQuery 1.8 中被删除。

如有必要,您仍然可以通过 $._data(element, "events") 访问它,尽管这不受官方支持,并且可以修改或删除该行为(如您所见)随时。

http://blog.jquery.com/2012/08/09/jquery-1-8-released/

$(element).data(“events”): In version 1.6, jQuery separated its internal data from the user’s data to prevent name collisions. However, some people were using the internal undocumented “events” data structure so we made it possible to still retrieve that via .data(). This is now removed in 1.8, but you can still get to the events data for debugging purposes via $._data(element, "events"). Note that this is not a supported public interface; the actual data structures may change incompatibly from version to version.

从 jQuery 1.9 开始,似乎不存在支持检索此数据的公共(public)接口(interface):

https://jquery.com/upgrade-guide/1.9/

Prior to 1.9, .data("events") could be used to retrieve jQuery's undocumented internal event data structure for an element if no other code had defined a data element with the name "events". This special case has been removed in 1.9. There is no public interface to retrieve this internal data structure, and it remains undocumented. However, the jQuery Migrate plugin restores this behavior for code that depends upon it.

关于javascript - 错误: Cannot read property 'blur' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34300652/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com