PDA

View Full Version : How to access the original created Ext.Object



pansenstar
23 May 2007, 7:54 AM
Hi all,

i'm starting to work with your great library but unfortunally i got stucked on writing an eventhandler. please see my code:


// creating any form object
var simple = new Ext.form.Form({
id: 'andisFirstForm',
labelWidth: 75,
url:'save-form.php'
});

// add a button
var resetButton = simple.addButton('Reset');
// create handler
function resetButton_Click(target, e){
var get = Ext.get('andisFirstForm');
// [1] this would work of course
simple.reset();
// [2] but this one not:
get.reset();
}
resetButton.on("click", resetButton_Click);


my problem is now that i could indeed use the [1] solution but i'm pretty sure that i will get in trouble if things become more complex. so i'm looking for the method/member that gives me the original object, here named 'simple' (means the <Ext.form.Form> object). via calling Ext.get() i only receive an <Ext.Element> (i guess) what does not help me, since i want to call the Ext.form.Form.reset() method...

thanks in advance,
andi

pansenstar
25 May 2007, 12:47 AM
hey all,

unfortunately i have no solution yet, but perhaps a screenshot of the debugger will help anybody to see my problem. the first screenshot shows the object that was originally created ('Ext.form.Form'). the second one shows the object, that i receive by calling Ext.get(<idOfTheForm>), which is a 'Ext.Element' object.

if anyone could tell me, how to reach the first object, by using the second one, that would be really great :)

http://www.doppelpop.de/problems/sshot-2007-05-25-%5B10-38-33%5D.png
http://www.doppelpop.de/problems/sshot-2007-05-25-%5B10-41-30%5D.png

liggett78
25 May 2007, 1:00 AM
I believe there is no way of getting Ext.form.Form or other from Ext.Element. So you have to store all your Form, Button etc. object references somewhere, e.g. globally.

Hope this helps,
Joerg

Animal
25 May 2007, 1:13 AM
Read the docs for Observable:



resetButton.on("click", resetButton_Click, simple);


That executes the fnuction in the scope of your form.

You shojuld be using objects.

pansenstar
25 May 2007, 1:20 AM
hey Animal,

thank you very much for your tip, this is the way i have to work (and i was looking for, although i did not see that :) )

best,
andi