1
使用JQuery時,擴展具有重寫的toString()函數的對象會導致Firefox中出現「Operation is not supported」錯誤。但在Chrome中,它工作正常。這是JQuery中的錯誤還是我在下面的代碼片段中做錯了?JQuery Extend - 在Firefox中不支持操作
var foo = function() {
var that = this;
that.toString = function() { return "foobar" };
return that;
}();
var foo2 = function() {
var that = this;
that = $.extend(true, {}, foo); // copy = options[ name ]; = "Operation is not supported" in Firefox 3.6.8
return that;
}();
alert(foo.toString()); //"foobar" in Chrome
alert(foo2.toString()); //"foobar" in Chrome
JQuery的版本1.4.2
非常感謝,
Godders
感謝您的回答。這促使我回去重讀克羅克福德的「優秀部分」一書中的4個調用模式。 – Godders 2010-08-23 15:12:37
好吧,所以我想要做的事情需要var that = {};在foo和foo2函數中。謝謝您的幫助。 – Godders 2010-08-23 15:23:30
不客氣!祝你好運! – Pointy 2010-08-23 16:42:28