开发者

jQuery in CouchApp and Internet Explorer 8

I am trying out a simple example from http://couchapp.org/page/what-is-couchapp, on Internet Explorer 8 and it just throws the 'object doesn't support this function or method' and the part that is pointed to is the 'forEach' method. I use CouchBase server 1.0.2 that comes with jQuery 1.4.2. There is no change when I replace the jquery.js with the 1.6 version. There already exists a patch for forEach in jquery.couch.app.js. Is there anything that I can do about this ?!

(Ultimately, I want to get the jQuery based jsTree working on IE, but IE doesn't even load the demo page that I saved locally.)

<!DOCTYPE html>
<html>
<head><title>Tiny CouchApp</title></head>
<body>
<h1>Tiny CouchApp</h1>
<ul id="databases"></ul>
</body>
<script src="/_utils/script/jquery.js"></script>
<script src="/_utils/script/jquery.couch.js"></script>
<script>
$.couch.allDbs({
  su开发者_运维百科ccess : function(dbs) {
    dbs.forEach(function(db) {
      $("#databases").append('<li><a href="/_utils/database.html?'+db+'">'+db+'</a></li>');
    });
  }
});

</script>
</html>

Thanks in advance.

EDIT

By changing the forEach to map and adding the following function to jquery.couch.app.js, the tiny app does work.

if (!Array.prototype.map)
{
Array.prototype.map = function(fun/*, thisp*/)
{
    "use strict";
    var len = this.length;
    if (typeof fun != "function")
        throw new TypeError();

    var res = new Array(len);       
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
        if (i in this)
            res[i] = fun.call(thisp, this[i], i, this);
    }

    return res;
};
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜