PDA

View Full Version : Adding and Removing Panels..Help



DavidGillespie
5 May 2011, 1:22 AM
Hello all!

I am having an odd problem with sencha touch which baffles me. I have very little experience with Javascript, so it may just be the silliest of errors. I am trying to do a compare between new carousels which are chosen on the panel before. Depending on the value of the selected form depends on the form being chosen. The code is as follows:



var get =Ext.getCmp('compare3');
console.log(name2);
if (name2 == 'Endurance'){
get.removeAll(true);
// get.remove(compa);
get.add(
compare2
);
compa = 'compare-2';
}else if (name2 == 'Hill'){
get.removeAll(true);
// get.remove(compa);
get.add(
compare3
);

compa = 'compare-3';


}else if (name2 == 'Cinema'){

moor.removeAll(true);
// moor.remove(compa);
moor.add(
compare4
);

compa = 'compare-4';
}

else if (name2 == 'Way to the GFs'){
get.removeAll(true);
// moor.remove(compa);
get.add(
compare5
);


compa = 'compare-5';
}

else if (name2 == 'Dundee - St Andrew'){


get.removeAll(true);
// get.remove(compa);
get.add(
compare6
);
compa = 'compare-6';
}

else if (name2 == 'Home - Tescos'){

get.removeAll(true);
// get.remove(compa);
get.add(
compare7
);
compa = 'compare-7';

}

else if (name2 == 'Cinema 2'){

get.removeAll(true);
//get.remove(compa);
get.add(
compare8
);

compa = 'compare-8';
}
else if (name2 == 'Way to the GFs 2'){
get.removeAll(true);
// get.remove(compa);
get.add(
compare9
);

compa = 'compare-9';

}

else if (name2 == 'Dundee - St Andrew 2'){

getremoveAll(true);
get.add(
compare10
);

get = 'compare-10';

}


moor.doComponentLayout();


Compa is just a string that changes depending on what is chosen. This code works once! It will removes everything in the panel and will add a carousel. Yet if i choose to go back and reselect from the form and press enter again it seems to remove the what was previously on the panel and does add the one of the courousels to the panel yet it isnt displayed unitl i resize the web browser i am developing in. This is baffling me. dont understand why its doing this.

Any help to deal with this problem wouldbe amazing!

Thanks

David Gillespie

jay@moduscreate.com
6 May 2011, 1:13 AM
David,

You need to regenerate the instance of the items that are in compare<NUM> references. After you've removed an item, it's automatically destroyed.

Please take a look at Sencha Touch in Action: http://manning.com/garcia2

DavidGillespie
6 May 2011, 2:17 AM
Thank you!

DavidGillespie
6 May 2011, 3:33 AM
Thank you for the code but i thik it's exactly what i posted at the start of this thread.

jay@moduscreate.com
6 May 2011, 3:57 PM
Thank you for the code but i thik it's exactly what i posted at the start of this thread.

what you responded to was a spam bot :)