Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE 8 does not support foreach method

This code not working in Internet Explorer 8.

documenttab.query('.field,.button').forEach(function(c){c.setDisabled(false);});

I get the error SCRIPT438: Object doesn't support property or method 'forEach'

like image 645
Sarika.S Avatar asked Jul 19 '12 07:07

Sarika.S


3 Answers

Mozilla also publishes code for methods which you can put near the top of your JS and it will create them if they don't exist.

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach

like image 87
Derek Avatar answered Sep 28 '22 00:09

Derek


I believe this should solve your issue.

vals = documenttab.query('.field,.button')
for (i = 0; i < vals.length; i++) {
    vals[i].setDisabled(false);
}
like image 33
Dan Avatar answered Sep 28 '22 01:09

Dan


Ext has a forEach method. Where supported, it will defer to the native method:

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Array-method-forEach

Ext.Array.forEach(documenttab.query('.field,.button'), function(c){
    c.setDisabled(false);
});
like image 22
Evan Trimboli Avatar answered Sep 28 '22 00:09

Evan Trimboli