jQuery IE将此绑定 [英] JQuery IE bind this

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

问题描述

在IE中,我使用JQuery在控制台中收到此错误:

In IE I am getting this error in the console using JQuery:

SCRIPT438:对象不支持属性或方法绑定" default.js,第33行字符3

SCRIPT438: Object doesn't support property or method 'bind' default.js, line 33 character 3

$.get(URL + 'dashboard/photoList/'+categoryID, (function(o) {
        // code here
}).bind(this));

是否有解决方法来绑定"this"?我已经习惯了原型.

Is there a work around to binding 'this'? I'm used to this from prototype.

推荐答案

bind仅在支持ECMAScript 5的浏览器中可用.与(显然)Prototype.js不同,jQuery不会扩展内置对象.

bind is only available in browsers supporting ECMAScript 5. Unlike (apparently) Prototype.js, jQuery does not extend built-in objects.

jQuery提供了 $.proxy [docs] :

jQuery offers $.proxy [docs]:

$.get(URL + 'dashboard/photoList/'+categoryID, $.proxy(function(o) {
        // code here
},this));

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

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