PDA

View Full Version : Button handler event with arguments



meshulro
22 Dec 2009, 2:01 AM
Hi everyone

I am trying to create a simple GUI where the user enters a word in the request textbox and get it echoed to the reply box, following i will communicate with server. But for now, even a simple copying between the boxes is not working. I marked the line which causes me the problem, can you please help me out here?

Using the following code :


...
var top = new Ext.FormPanel( {
frame : true,
items : [ {
layout : 'form',
items : [ {
xtype : 'textfield',
fieldLabel : 'Request',
id : 'request',
}, {
disabled : true,
xtype : 'textfield',
fieldLabel : 'Reply',
id : 'reply'
} ]
} ],

buttons : [ {
text : 'Submit',
handler : this.submit,
request : top.findById('request').getValue() <--> NOT WORKING
} ]
});

submit : function(b, e){
if(b.request.length == 0)
{
b.request = 'Empty';
}
top.findById('reply').setValue(b.request);
}
Thank you very much,
Roy

tot2ivn
22 Dec 2009, 3:08 AM
This should do the simply copy/paste as you want to:



Ext.onReady(function(){

var myForm = new Ext.FormPanel({
renderTo: Ext.getBody(),
id: 'myForm',
items: [
{
fieldLabel: 'Request',
xtype: 'textfield',
id: 'request'
},
{
fieldLabel: 'Reply',
xtype: 'textfield',
id: 'reply'
}
],

buttons: [
{
text: 'Submit',
handler: function() {
if((request = myForm.findById('request')) &&
(reply = myForm.findById('reply')))
{
reply.setValue(request.getValue());
}
}
}
]
});
});



Cheers,

Totti

meshulro
22 Dec 2009, 5:25 AM
Thank you very much,
Roy