Uncaught Ext.AbstractManager.register (): Rejestrowanie duplikatu identyfikatora
W poniższej aplikacji próbuję dodaćid
do generowanych elementów dynamicznie. Mój kod działa poprawnie, ale gdy dodam w nim dwie poniżej skomentowane linie. Zgłasza błąd
Uncaught Ext.AbstractManager.register (): Rejestrowanie duplikatu identyfikatora „73” u tego menedżera
Kiedy próbowałem znaleźć źródło błędu, odkryłem, że kod działa dobrze do czasu wykonania81
id's (console.log(_idGen)
). Z tego wynika, że błąd dotyczy wyjątku poza zakresem. (9 * 9 = 81), a takżetylko w Fiddle, kiedy dodaję tekst HTML do paneli podrzędnych, dowiedziałem się, że są między nimi73 to 81
??(zamiast1 to 81
) co mnie wprawia w zakłopotanie?
Ext.onReady(function(){
var _idGen = 1;
var childItems = [], items = [];
for (var i = 0; i < 9; i++) {
childItems.length = 0;
for (var j = 0; j < 9; j++) {
childItems.push({
xtype: 'panel',
/****************************/
id: _idGen,
html: _idGen + "",
/****************************/
width: 50,
height: 50,
style: {borderWidth: '1px'}
});
console.log(_idGen);
/*****************************/
_idGen++;
/*****************************/
}
items.push({
xtype: 'panel',
layout: {
type: 'table',
columns: 3
},
items: childItems
});
}
Ext.create('Ext.container.Container', {
layout: {
type: 'table',
// The total column count must be specified here
columns: 3
},
renderTo: Ext.getBody(),
style: {width: '455px',marginLeft: 'auto',marginRight: 'auto', marginTop: '30px'},
items: items
});
});