jQuery和prototype不能与Array.prototype.reverse一起工作
jQuery and prototype don't work together with Array.prototype.reverse
我使用prototype.js和jquery在一起,我得到这个错误信息
Uncaught TypeError: Object [object Object] has no method '_reverse' (Chrome)
我在
之前调用了jQuery.noConflict
我使用jQuery.fn.reverse = [].reverse;
对jQuery集合有反向功能
如果你使用的是无冲突模式的jQuery,你必须在
中添加反向函数jQuery.fn.reverse
prototype覆盖了原生的Array.protoype.reverse
Function,将原来的Array.prototype._reverse
保存。
这个片段考虑到了这一点
if (typeof []._reverse == 'undefined') {
$.fn.reverse = Array.prototype.reverse;
} else {
$.fn.reverse = Array.prototype._reverse;
}
旧的错误解决方案
// for compatibility with prototype.js
if (![]._reverse) {
[]._reverse = [].reverse;
}
jQuery.fn.reverse = [].reverse;
相关文章:
- 直接在函数声明上使用function.prototype.bind
- 如何迭代Array.prototype函数
- 我怎样才能制作一个“;reverse preventDefault”;在jQuery中
- Object.prototype using 'this'
- 在不兼容的接收器上调用的方法Set.prototype.add未定义
- 为什么可以't我用Set对象调用Array.prototype.map
- ExtJS 4 Object.prototype fail
- 如何通过Prototype或jquery移除子类的父类基类
- 复选框:使用Array.prototype.forEach调用推送选中订单,
- 将setTimeout()包装器实现为Element.prototype中的方法
- Object.prototype.hasOwnProperty.call() vs Object.prototype.h
- 如何通过 Function.prototype.apply() 更改调用函数的参数
- Function.prototype.call和Function.protoype.all只应用一个参数
- 使用JavaScript或Prototype获取表单中的所有控件并启用它们
- JavaScript-使用B.prototype=new A()继承数组
- 转换类似数组的对象Array.prototype.slice或Array.from
- requestAnimationFrame的Function.prototype.bind导致属性不可读
- Javascript中的Array.prototype.reverse和Array.reverse有什么区别
- jQuery和prototype不能与Array.prototype.reverse一起工作
- 试着理解这个函数:Array.prototype.reverse = function(){