Reputation: 1780
I've a simple model -
Ext.define('MyModel', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.field.String'
],
fields: [
{
type: 'string',
name: 'currentA'
},
{
type: 'string',
name: 'currentB'
},
{
name: 'A'
},
{
name: 'B'
}
]
});
Here is some operation that I'm doing on the data for that model-
onBeforeRender: function(component, eOpts) {
var mystore = Ext.getStore('Mystore');
mystore.load({
callback: function(){
var entity = headerStore.getAt(0);
var bs = entity.data.B;
var as = entity.data.A;
var currentB = entity.data.currentB;
var currentA = entity.data.currentA;
bs.forEach(function(record) {
// do some operations
});
as.forEach(function(record) {
// do some other operations
});
}
});
}
Now, when iterating over variable "bs", which is clearly an array of objects, IE 8 complains
"Object doesn't support this property or method"
for the forEach function. This works fine in Chrome.
Here is the json for the model -
{
"currentA": "a",
"currentB": "b",
"A": [
{
"name": "a",
"id": 1
}
],
"B": [
{
"name": "b",
"id": 2
}
]
}
Why is IE not able identify it as an array?
Upvotes: 2
Views: 7983
Reputation: 77482
You can use .each
from Ext.Array
, because IE8 does not support .forEach
Ext.Array.each(bs, function(record) {
});
Ext.Array.each(as, function(record) {
});
[].forEach
does not depend on ExtJS version because this is JS Array's method which was added in ES5
standard. From this link
you can see which browser supports forEach
method.
Upvotes: 5
Reputation: 30082
Because IE8 doesn't implement forEach
on arrays.
Use Ext.Array.forEach
.
Upvotes: 1