Results 1 to 5 of 5

Thread: Can I add my handler like this to Designer code?

  1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    93

    Default Can I add my handler like this to Designer code?

    n/a

  2. #2
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061

    Default

    First post looks better than the 2nd.

    I don't see why you want to avoid calling getCmp() - it's fast.

  3. #3
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061

    Default

    My code tends to look like this:

    Code:
    LoginWindowUI = Ext.extend(Ext.Window, {
      initComponent: function() {
        var me = this;
        var myId = Ext.id();
        var config = {
          layout: 'form',
          id: myId,
          items: [
          ...
          ]
        };
        Ext.apply(this, ext.apply(this.initialConfig, config));
        this.bbar = new Ext.Toolbar({
          items: [
            {
               text: 'Login',
               handler: function() {
                 Ext.getCmp(myId).getForm().submit({
                   ...
                 });
               }
            }
         ]
        });
        LoginWindowUI.superclass.initComponent.apply(this, arguments);
    });

  4. #4
    Sencha User mschwartz's Avatar
    Join Date
    Nov 2008
    Location
    San Diego, Peoples' Republic of California
    Posts
    2,061

    Default

    Though I rarely use form.submit() - only if there's a file upload.

    I'd do Ext.getCmp() on each of the fields and validate them and then use Ext.Ajax.request() to post to the server.

  5. #5
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,488

    Default

    I would suggest setting itemId's on the components that are contained within your top level Container.

    You can then use getComponent which is scoped by itemId before id. This will make it so that your LoginWindow class can be re-used and does not run into id collisions.
    Aaron Conran
    @aconran

Posting Permissions

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