PDA

View Full Version : [SOLVED] Understanding Namespace and Ext.regApplication



Kurt001
2 Jun 2011, 2:34 PM
Hi there,

I am having two *.js files.
1) index.js, which holds

Ext.regApplication({
name: 'dropMe',
launch: function() {

var board = new Ext.Panel
({
layout: "card",
items: [],
dockedItems: [],
});
var myBoardFiller = new fillBoard();
myBoardFiller.doTheFill();
}2) helper.js which holds:


function fillBoard(){
this.doTheFill = function(){
var myText = new Ext.form.Text();
myText = {
name: 'textName',
label:'textLabel'
}
dropMe.board.add(myText);
}
}But it reports back that dropMe.board is not an object.
Whats wrong?

Best TD

StuartAshworth
3 Jun 2011, 12:25 AM
Instead of defining 'board' as a local variable you will need to define it as a property of the dropMe namespace object. So instead of "var board = ..." change it to "dropMe.board = ..."

Kurt001
3 Jun 2011, 1:32 AM
Hi,
now I changed it like this:


function fillBoard(){
this.doTheFill = function(){
var myText = new Ext.form.Text();
myText = {
style: "background-color:green;",
name: 'textName',
label:'textLabel'
}
dropMe.board.add(myText);
dropMe.board.update();
}
}


Ext.regApplication({
name: 'dropMe',
launch: function() {

dropMe.board = new Ext.Panel({
fullscreen: true,
style: "background-color:#dadee2;",
layout: "card"
});

var myBoardFiller = new fillBoard();
myBoardFiller.doTheFill();
}
})

But update does not work. If I change the size of Safari, it shows up.
What is wrong here?

Best TD

StuartAshworth
3 Jun 2011, 1:34 AM
Replace "dropMe.board.update();" with "dropMe.board.doLayout()"

Kurt001
3 Jun 2011, 1:46 AM
Great, thanks.