Results 1 to 2 of 2

Thread: Listeners defaults aren't merged automatically

  1. #1
    Sencha User
    Join Date
    Mar 2016
    Posts
    99
    Answers
    5
    Vote Rating
    29
      1  

    Default Listeners defaults aren't merged automatically

    There's already this thread https://www.sencha.com/forum/showthr...276#post484276

    My question is - why listeners from defaults still (after 5-6years) aren't merged automatically with other listeners?

    Code:
    xtype: 'form',
    defaults: {
      listeners: {
        specialkey: function( field, e ) {
          if ( e.getKey() == e.ENTER && field.isValid() && !me.queryById('acceptBtn').disabled ) {
            me.fireEvent('accept');
            me.close();
          }
        }
      }
    },
    
    items: [
    ....
    {
      xtype: 'textfield',
      listeners: {
        change: function( field ) {
    
    ...

  2. #2
    Sencha User
    Join Date
    Mar 2016
    Posts
    99
    Answers
    5
    Vote Rating
    29
      1  

    Default

    I solved it like this

    Code:
    var defaultListeners = {
      specialkey: function( field, e ) {
        if ( e.getKey() == e.ENTER && field.isValid() && !me.queryById('acceptBtn').disabled ) {
          me.fireEvent('accept');
          me.close();
        }
      }
    };
    
    ...
    
    xtype: 'form',
    defaults: {
      listeners: defaultListeners
    },
    items: [
    ...
    {
      xtype: 'textfield',
        listeners: Ext.applyIf({
          change: function( field ) {}
        }, defaultListeners)
    ...
    but my question stands - why apply ugly hacks and workarounds if it can be solved at the core of the problem instead?

Similar Threads

  1. Replies: 1
    Last Post: 11 Sep 2014, 4:43 AM
  2. Replies: 2
    Last Post: 29 Jan 2013, 2:08 PM
  3. [OPEN] Floatable panels aren't added to a viewport or a defined parent automatically
    By Steffen Hiller in forum Sencha Touch 2.x: Bugs
    Replies: 5
    Last Post: 21 Mar 2012, 12:05 PM
  4. How to use panel's resizable attribute - panels aren't resizing automatically
    By gwinning in forum Ext Designer: Help & Discussion
    Replies: 0
    Last Post: 15 Mar 2012, 7:24 AM
  5. Can't set listeners in Container.defaults?
    By joethu in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 6 Oct 2009, 11:25 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
  •