PDA

View Full Version : how to alert the DIV in panel



yanasdf789
20 Jan 2011, 2:11 AM
i have a panel with 'div',how to i alert the 'div'?







var newpanel = new Ext.Panel({
frame:true,
id:'pp',
height:200,
title:'new',
contentEl:'div1',
autoScroll: true

});
html: <div id="div1">111</div>
<div id="div2">222</div>



how to alter the contentEl with 'div2'?

like this:
Ext.getCmp('pp'). contentEl ="div2";
Ext.getCmp('pp').getUpdater().refresh();

this is wrong! how do i to it?

vishalnnsingh
20 Jan 2011, 3:13 AM
This is how you change the content

new Ext.Panel({
frame:true,
id:'pp',
height:200,
title:'new',
contentEl:'div1',
autoScroll: true,
listeners:{
render:function(){
Ext.get('div1').update('Hello World');
}
}
});

yanasdf789
20 Jan 2011, 4:07 AM
thank you for vishalnnsingh! if i don't know the content of div,how to i alter the contentEI according to the id of '<div>'?
how to i alter the contentEI by function of button's click()!

yanasdf789
20 Jan 2011, 9:15 PM
can you help me?

vishalnnsingh
20 Jan 2011, 10:23 PM
{
xtype:'button',
text:'Click Me',
handler:function(){
Ext.get('div1').update('Hello World');
}
}
This can be done to change the content on button click, i really cannot understand your second question, please elaborate..

yanasdf789
21 Jan 2011, 8:40 PM
i mean if i dont't know the content of the <div> like "Hello Word",but i know the id of new <DIV>, HOW do it?

Ext.get('div1').update('div2'); //is it ok?

Condor
22 Jan 2011, 8:35 AM
Ext.getCmp('pp').update(Ext.getDom('div2').innerHTML);