kashim
25 Jan 2012, 7:56 AM
Hi
(I might be going about this the totally wrong way so forgive my ignorance).
I am creating a form Panel with its layout coming from another js file (lets call it sub.js).
When I click a button on the form Panel, I want call a function in sub.js. However I keep getting an error.
Ext.onReady(function () {
var item1 = [];
Ext.Object.each(getSubForm(), function (name, example) {
item1.push(example);
});
Ext.create('Ext.form.Panel', {
title: 'Simple Form',
bodyPadding: 5,
width: 350,
// Fields will be arranged vertically, stretched to full width
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: item1,
buttons: [{
text: 'test',
handler: function () {
item1.funcA(); // Cant call funcA()
}
}],
renderTo: Ext.getBody()
});
});
sub.js
function getSubForm() {
function funcA(data_array2) {
alert('funcA() called');
}
return {
whatever: { xtype: 'container', layout: 'vbox', id: 'vbox1', margin: '5 0 0 5',
items: [
{ xtype: 'textfield', id: 'sub1', fieldLabel: 'sub1', labelWidth: 30, width: 200, margin: '5' },
{ xtype: 'textfield', id: 'sub2', fieldLabel: 'sub2', labelWidth: 30, width: 200, margin: '5' },
{ xtype: 'textfield', id: 'sub3', fieldLabel: 'sub3', labelWidth: 30, width: 200, margin: '5' }
]
}
}
}
What I would like to do is create layouts with a few functions in their own.
thanks
kashim
(I might be going about this the totally wrong way so forgive my ignorance).
I am creating a form Panel with its layout coming from another js file (lets call it sub.js).
When I click a button on the form Panel, I want call a function in sub.js. However I keep getting an error.
Ext.onReady(function () {
var item1 = [];
Ext.Object.each(getSubForm(), function (name, example) {
item1.push(example);
});
Ext.create('Ext.form.Panel', {
title: 'Simple Form',
bodyPadding: 5,
width: 350,
// Fields will be arranged vertically, stretched to full width
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: item1,
buttons: [{
text: 'test',
handler: function () {
item1.funcA(); // Cant call funcA()
}
}],
renderTo: Ext.getBody()
});
});
sub.js
function getSubForm() {
function funcA(data_array2) {
alert('funcA() called');
}
return {
whatever: { xtype: 'container', layout: 'vbox', id: 'vbox1', margin: '5 0 0 5',
items: [
{ xtype: 'textfield', id: 'sub1', fieldLabel: 'sub1', labelWidth: 30, width: 200, margin: '5' },
{ xtype: 'textfield', id: 'sub2', fieldLabel: 'sub2', labelWidth: 30, width: 200, margin: '5' },
{ xtype: 'textfield', id: 'sub3', fieldLabel: 'sub3', labelWidth: 30, width: 200, margin: '5' }
]
}
}
}
What I would like to do is create layouts with a few functions in their own.
thanks
kashim