I’m instantiating a class when a button is clicked. How do I get a reference to this class instance outside of the button callback?
handler: function() {
var formValues = Ext.getCmp('DonateItemForm').getValues(),
itemDetails = Ext.create('App.model.ItemDetails', formValues);
}
Edit: Without using a global
You should store the model instances in the controller that manages your panel(view).
However, if you are not coding according to the model-view-controller pattern, then you can attach it to the donate form:
But the basic idea should be clear:
Every time you want to access the model instance, just go through the object that manages it (either the form controller or the form itself).
[edit]
To store your data in the controller, you need to first send it to that controller:
Basically, your handler should send the data to your controller by dispatching a message to it. The message will contain the payload that contains the form data you want to send.
“yourDetails” will now hold the itemDetails that you need. Of course you can name it anything you want and you can add more members to the dispatched message if you like.
Now you need to make a method called “MethodOnYourController” that can catch this event:
I haven’t tested this code, but the idea should be pretty clear.