PDA

View Full Version : add() and remove() extjs4



hervest
24 May 2012, 2:58 AM
I have 2 panels (center panel and west panel). the first one (west panel) have a button. What i want to do is that when i click on my button, my form appear on the center pannel. For that i have used this code



xtype:'button',
text: 'Button 1',
handler: function(){ replace(cardWizard, 'wizard');
}





var currentName;
var replace = function(config, name) {
var cp = Ext.getCmp('centerPanel');
if (name && name != currentName) {
currentName = name;
cp.remove(0);
cp.add(Ext.apply(config)); }
}

Now when i click on my button, my form appear, in second time the component of my form start deseapearing, once time again, the same thing arrives until the total dispearance of the form. It's like the add() fonction work only one time. it is the best ways i have done it? why my form deseaper? i want to set up a small software with button on west panel and form on center panel.

el_chief
24 May 2012, 12:48 PM
can you try this sentence again? it is not clear

"
in second time the component of my form start deseapearing, once time again, the same thing arrives until the total dispearance of the form. It's like the add() fonction work only one time"

1. learn Firebug, and see what is actually going on. Use the debug versions of the libraries. Learn the debugger; javascript statement. Learn about breakpoints, and stepping through and over functions.

2. read up on the documentation of MixedCollections, that is the type that the Card panel uses

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.util.MixedCollection

3. consider the setActiveItem() method of CardLayout

http://docs.sencha.com/ext-js/4-1/#!/api/Ext.layout.container.Card-method-setActiveItem

4. Put your code on JSFiddle so we can help you

Man, wouldn't it be awesome if Sencha had the following...

1. Their own version of JSFiddle that was a little more Ext or Touch friendly?! Maybe you could partner with them! Have the latest versions of the libraries, auto style sheets. Good times.

2. A forum more like Stackoverflow with voting and stuff.