Question

I need to pass instance of my MessageBox so I can close it inside the success function of my Ajax request which is inside the controller. This way, i won't need to add refs for controller to look for my messagebox.

this.win = Ext.create('Ext.window.MessageBox',{
    buttonAlign: 'left'      
   ,buttons:[
    {
      text: "This Only"
     ,scope:this
     ,handler: function() {
        this.fireEvent("eventName",{type:"all",  // i presume my messagebox is simply passed in here, I just dont know HOW });
      }
    }
  ]

thank you in advance!

Was it helpful?

Solution

You'll need to pass a reference in the event being fired, e.g.

this.fireEvent("eventName",{type:"all", this.up('window') });

You pass this.up('window') as this refers to the button being clicked, you need to traverse the DOM upwards to get the parent window. Then in your event, you have access to the window instance as the second argument in the event- and can do with it what you will (.e.g window.close();)

n.b. off the top of my head I cant remember if you may be better off using this.up('messagebox')

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top