将.on添加到jQuery .16.1 [英] adding .on to jQuery .16.1

查看:61
本文介绍了将.on添加到jQuery .16.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我处于需要为CMS运行jQuery 1.6.1的情况,但是我们正在使用的上载插件使用jQuery 1.7的.on函数.

I'm in a situation where I need to run jQuery 1.6.1 for a CMS, however the upload plugin we're using uses jQuery 1.7's .on function.

我想知道是否有一种方法可以扩展1.6以包含.on功能.

I was wondering if there was a way we can extend our 1.6 to include .on functionality.

非常感谢

推荐答案

除非您有其他非前向兼容插件,否则我不明白不升级到最新jQuery版本的意义.

Unless you have other non-forward compatible plugins I don't really see the point of not upgrading to a more recent jQuery version.

尽管如此,这是尝试利用特征码之间的相似性修补猴子.不过,这可能很脆弱,因此您可能还必须补偿其他签名,具体取决于插件使用on的方式.

Nevertheless, here's an attempt at monkey patching, taking advantage of the similarity between signatures. This is likely to be brittle though, so you might have to compensate for other signatures as well, depending on how the plugin uses on.

jQuery.fn.extend( {
        on: function(eventsmap, selector, data, handler) {
            return this.delegate(selector, eventsmap, data, handler)
        }
});

这篇关于将.on添加到jQuery .16.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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