Results 1 to 4 of 4

Thread: Component Listeners - Delegating Single Event to Multiple Classes

  1. #1
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    4
    Vote Rating
    1
      0  

    Default Component Listeners - Delegating Single Event to Multiple Classes

    How do we go about delegating an event to multiple classes?

    I've tried the following 2 methods and it doesn't work for me.
    HTML Code:
     xtype: "container",
    listeners: {
        tap: {
            fn: function(e) { 
                    var el = e.target;
                },
            element: 'element',
            delegate: '.classA, .classB',
            scope: this
        }
    }
    and

    HTML Code:
    xtype: "container",
    listeners: {
        tap: {
            fn: function(e) { 
                    var el = e.target;
                },
            element: 'element',
            delegate: ':(.classA|.classB)',
            scope: this
        }
    }

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,380
    Vote Rating
    1525
      0  

    Default

    Do you mean CSS classes or ST classes?
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    4
    Vote Rating
    1
      1  

    Default

    CSS Style

    HTML Code:
     xtype: "container",
    html: "<div class='classA'>Click me</div><div class='classB'>Click me</div>"
    listeners: {
        tap: {
            fn: function(e) { 
                    var el = e.target;
                },
            element: 'element',
            delegate: '.classA, .classB',
            scope: this
        }
    }

  4. #4
    Sencha User
    Join Date
    Jul 2013
    Posts
    4
    Vote Rating
    0
      0  

    Default

    I am kind of wondering about the same thing.
    How to delegate an event to multiple components. Is this possible in general?


    (This code should scroll the page to a certain Y position, when a textfield is focused to prevent a keyboard on android from covering this textfield.)
    PHP Code:
    listeners: [
            {
                
    event'focus',
                
    fn: function(compeeopts) {
                    var 
    ost comp.element.dom.offsetTop;
                    
    this.getScrollable().getScroller().scrollTo(0ost);
                },
                
    delegate: [ '#id1''#id2''#id3' ]      //how to do something like this
            

        ], 
    (Consider #idX to be an id of a textfield inside a fieldset.)

Posting Permissions

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