1

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({
  success : 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;
};
}
soumya
  • 278
  • 3
  • 8
  • See http://stackoverflow.com/questions/2726684/how-to-get-jquery-couch-app-js-to-work-with-ie8 – bobince May 30 '11 at 15:08
  • Thank you for that, I was looking for that particular link. That's the patch I tried before I posted the question, replacing it in the said js file, to no avail. I continue to get the same error. Any more tips ? Thanks. – soumya May 30 '11 at 15:25
  • There's not a patch there, just a couple of extra functions to drop into the `Array.prototype` before including the other scripts. – bobince May 30 '11 at 15:48
  • Am sorry, I meant those functions (I also have added one for map that I would use in other part of App), but like I said earlier, those extra functions for Array.prototype don't seem to do any magic in this case :( – soumya May 30 '11 at 19:19
  • I must add here that even Futon doesn't load completely on IE 8, first it throws the same 'function not supported' error and then shows the list of DBs and then the login part is missing. – soumya May 30 '11 at 19:27

0 Answers0