0

probably is a stupid question but i really don't know now, what i have to do to localize a button in a window i just redefined and create. I use extjs 4.2.1 and i produce a kind of mvc but is more similar to the old way of use this type of framework.

I have to define a window that have two buttons 'submit' and 'close' like this:

Ext.define('newWindow',{
    extend:'Ext.window.Window',

    config: {
        submitFn:function(){return null;}
    }
    bodyStyle: 'padding: 5px 5px 0',
    layout:'fit',
    width:460,
    height:390,
    plain: false,
    border:false,
    resizable: false,
    buttons: [{
        text:'submit',
        handler: function(){this.up.up.submitFn()},
        tabIndex:1000
    },{
        text: 'close',
        handler: function(){
            this.up().up().hide();},
        tabIndex:1001
    }]
})

When i create this window in my code i want to pass him a function to handler his behave but i can't.. i try to put him itemId, id but Ext.getCmp(id), Ext.ComponentQuery.query(id) doesn't do their job.

RE-EDIT:

OK the question isn't clear: I define in that way the components newWindow. I say i don't use the mvc pattern and in a part of my program i create this component in like here;

var dlg = Ext.create('newWindow', {submitFn: submit});

Where submit is the function i need to call to submit the value present in the window, with her logic. This is what i need to do but i ask all another way to do that.

AfanfeFana
  • 159
  • 4
  • 15
  • The `fmt:message` tag is not something from ExtJS... You know that, right? Now, can you show the function call you want to make, if you can get a reference to the button (what you are apparently trying to do with `Ext.getCmp`? – rixo Jun 05 '13 at 17:55

2 Answers2

0

You could always just set the window's config closable:true instead of defining your own button.

cclerv
  • 2,921
  • 8
  • 35
  • 43
  • 2
    I don't think this is answering the question, he also needs a submit button, and maybe other things to do in the controller – Amit Aviv Jun 05 '13 at 18:00
  • Probably stepped over the line, but your answer still doesn't answer the question at all, it doesn't make any sense as to why someone up-voted it. – Reimius Jun 05 '13 at 21:29
  • @cclerville yes i can but i need to implement this kind of interface with a window with two button in the bottom. I know is redundant but i have to do my job in this way. – AfanfeFana Jun 06 '13 at 11:30
0

I assume all the ways you have tried to get a reference to the button didn't work because the button wasn't created when you called them. You should either wait for the button to be rendered when calling Ext.getCmp or use this.control in your controller init method. Here is an example:

Ext.define('myController', {
    extend: 'Ext.app.Controller',
    init: function() {
        this.control({
             '#submitButton': {
                 click: this.onSubmitButtonClick
             }
         });
     },

     onSubmitButtonClick: function() {
         console.log('Click');
     }
});

And here is a fiddle

Amit Aviv
  • 1,816
  • 11
  • 10