PDA

View Full Version : How can I call?



Riaz
23 Mar 2011, 7:48 PM
I have following code.

In jsEntryTimesheet.js


var x = new Ext.form.FormPanel({
:
});


Ext.reg("jsEntryTimesheet", x);



And in jsTimeAndExpenses.js


btnTimesheet = new Ext.Button({
ui:'round',
text: 'Timesheet',
flex: 1,
handler: function () {
// need to call "x of jsEntryTimesheet"

}

});

How do I call x object which is in "jsEntryTimesheet.js", when I click on "Timesheet" button?

Riaz
23 Mar 2011, 8:36 PM
I have got a solution, but not sure whether it is correct way or not.


In jsEntryTimesheet.js


var x = Ext.extend(Ext.Button, {
text: 'Timesheet',
handler: function () {
new Ext.form.FormPanel({
:
})
}
});

Ext.reg("jsEntryTimesheet", x);



And in jsTimeAndExpenses.js


TimeAndExpeses = Ext.extend(Ext.Panel, {
title: 'Time and Expenses',
iconCls: 'time',
fullscreen: true,
items: [{
xtype: "fieldset",
title: "Time and Expenses",
items: [{
xtype: 'jsEntryTimesheet'

}]
} ]
});


Hope, it will help somebody.

jay@moduscreate.com
24 Mar 2011, 4:43 AM
Yes that works. The issue is that you need to be thinking outside the realm of "files" and think about JavaScript as a global pool.