PDA

View Full Version : initComponent gets Skipped



eryx
15 Sep 2011, 2:43 AM
Hi there I'm working with Sencha Touch for almost two weeks and I really like it.

But I really need your help because I'm really stuck at the moment.

I have a List with a Detailpanel. When I click in the list it correctly goes to the detailpanel, calls the initComponent and displays all my stuff the correct way. When I then use the back button and click again on the same listelement ( and only if it is the same again) it switches to the detailpanel, but skippes the initComponent function. It does then all functions inside the initComponent function and when those are finished it calls the InitComponent correctly and does all over again.


bscyb.views.Spieledetail = Ext.extend(Ext.Panel, {
id: 'spieledetail',
scroll: 'vertical',
layout: 'fit',

initComponent: function(){
var dateArray = new Array();

var spieledetailtpl = new Ext.XTemplate(
'<div class="spielecontainer">',
'<tpl for=".">',
'<tpl if="this.checkForMultiple(values.datum) == true">',
'<div class="datum float">{datum}</div>',
'<table class="tabledetail">',
'</tpl>',
'<tr>',
'<td>{nameheim} - {namegast}</td>',
'</td>',
'<tr>',
'<td><p class="time float">{time}</p><img class="logoheim" src="images/icons/{logoheim}"/> {toreheim}:{toregast} <img class="logogast" src="images/icons/{logogast}"/></td>',
'</td>',
'<tpl if="this.checkForLast(values.idgast, values.idheim) == false">',
'</table>',
'<br />',
'</tpl>',
'<tpl if="this.checkForLast(values.idgast, values.idheim) == true">',
'<tr>',
'<td class="cut"></td>',
'</tr>',
'</tpl>',
'</tpl>',
'</div>',
{
checkForMultiple: function(datum) {
//jQuery.inArray(datum, dateArray) != -1
if(true) {
console.log("found date in array, no need to push");
return false;
} else {
dateArray.push(datum);
console.log("pushin in array");
return true;
}
}
},
{
checkForLast: function(gast, heim) {
storeobj = bscyb.stores.spieledetailstore;

for(var i = 0; i < storeobj.data.length; i++) {
if(gast == storeobj.data.items[i].data.idgast && heim == storeobj.data.items[i].data.idheim) {
var tempdate = storeobj.data.items[i].data.datum;
if(i+1 < storeobj.data.length) {
if(storeobj.data.items[i+1].data.datum == tempdate) {
return true;
} else {
return false;
}
} else {
return false;
}
}
}
}
}
);

this.listpanel = new Ext.DataView({
fullscreen: true,
store: bscyb.stores.spieledetailstore,
tpl: spieledetailtpl,
itemSelector: 'item',
});

this.dockedItems = [{
xtype: "toolbar",
title: this.record.data.c + ". Spieltag",
items: [{
text: 'Spiele',
ui: 'back',
handler: function() {
Ext.getCmp('spielecard').setActiveItem(this.prevcard, {
type: 'slide',
reverse: true,
scope: this,
});
}
}]
}]

this.items = this.listpanel;

bscyb.views.Spieledetail.superclass.initComponent.call(this, console.log("calling superclass initComponent"));
}
});

Ext.reg('spieledetail', bscyb.views.Spieledetail);

Sorry for my bad english I hope you can understand what I mean.

Greetings from Switzerland
eryx

mitchellsimoens
15 Sep 2011, 4:46 AM
When you hit back do you destroy the detailpanel?

initComponent will only get called when creating the class. If you want something that happens when you activate the component, add a listener for the activate event. So when you go back to the detailpanel, the activate event will fire and you can do as you wish. (also not the deactivate event).

eryx
15 Sep 2011, 10:36 PM
Hi thank you very much for your answer. I could solve my problem. I do know destroy my component each time I hit de back button.