Results 1 to 6 of 6

Thread: function scope change.

  1. #1
    Ext User
    Join Date
    Jul 2010
    Posts
    20

    Default function scope change.

    i have this example:
    Code:
    Ext.onReady(function(){
    
    
    new Ext.Window({
    
        title    : "Window",
        height    : 400,
        width    : 400,
        items    : new Ext.FormPanel({
            labelWidth: 75,
            frame:true,
            title: 'Simple Form',
            width: 350,
            defaults: {width: 230},
            defaultType: 'textfield',
            items: [{
                    fieldLabel: 'First Name',
                    name: 'first'
                }],
            buttons: [{
                text: 'Some function',
                handler: function()    { <!--function must close window-->  }
                }]
        })
    }).show()
    })
    what need do, that function close window?

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    You could use:
    Code:
    handler: function(btn){
      var win = btn.findParentByType('window');
      win[win.closeAction]();
    }

  3. #3
    Ext User
    Join Date
    Jul 2010
    Posts
    20

    Default

    wow, first time see this:
    Code:
    win[win.closeAction]();
    why not:
    Code:
    win.close()
    what principle different?

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    It's what the [x] button at the top does too.

  5. #5
    Ext User
    Join Date
    Jul 2010
    Posts
    20

    Default

    do you have some other examples this syntax?

  6. #6
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246

    Default

    A very common use is:
    Code:
    element[bool ? 'addClass' : 'removeClass'](someClass);

Similar Threads

  1. How to change/update gridpanel from function outside Ext.onReady function?
    By saadkhan in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 20 Feb 2010, 11:12 AM
  2. Problem with scope in handler function
    By r.kalff in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 7 May 2008, 5:27 AM
  3. callback function and scope
    By dddu88 in forum Ext 2.x: Help & Discussion
    Replies: 10
    Last Post: 18 Nov 2007, 11:11 AM
  4. how can i use the scope function of object?
    By koffdsa in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 12 Oct 2007, 7:57 AM
  5. Function parameter keeping scope?
    By SteveEisner in forum Community Discussion
    Replies: 2
    Last Post: 3 Nov 2006, 3:00 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •