Results 1 to 3 of 3

Thread: How to get the event name inside a controller

  1. #1
    Sencha User
    Join Date
    May 2015
    Posts
    31
    Answers
    1

    Default Answered: How to get the event name inside a controller

    Hello,

    How can i get the eventname inside an eventhandler?

    Use case: I want to define one eventhandler that is called by different listerners, so something like (example uses global events, but its similar for other event domains):

    PHP Code:
        ,listen: {
            global: {
                
    online'onOnline'
                
    ,connect'onOnline'
            
    }
        }

    ,
    onOnline: function(x,y,z) {
    // how to get the eventname here???
        
    switch(eventName) {
            case 
    'online':
                break;
            case 
    'connect':
                break;
        }

    P.S. I do not want to pass the eventname itself as a parameter to the event.

    Thanks in advance

    Wolfgang

  2. The event name isn't passed, you would need to do something like:

    Code:
    online: 'onOnline',
    connect: 'onConnect',
    
    onOnline: function() {
        doStuff('online');
    },
    
    onConnect: function() {
        doStuff('connect');
    }

  3. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256
    Answers
    759

    Default

    The event name isn't passed, you would need to do something like:

    Code:
    online: 'onOnline',
    connect: 'onConnect',
    
    onOnline: function() {
        doStuff('online');
    },
    
    onConnect: function() {
        doStuff('connect');
    }
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  4. #3
    Sencha User
    Join Date
    May 2015
    Posts
    31
    Answers
    1

    Default

    Thank you

    Best regards

    Wolfgang

Similar Threads

  1. Replies: 2
    Last Post: 27 Jan 2014, 2:00 PM
  2. Get tap event in Controller from a html div inside Img panel
    By Mike6679 in forum Sencha Touch 2.x: Q&A
    Replies: 3
    Last Post: 20 Jul 2012, 6:45 AM
  3. fire event from a controller to b controller
    By linuxyf in forum Sencha Touch 2.x: Discussion
    Replies: 1
    Last Post: 16 Jan 2012, 6:28 AM

Tags for this Thread

Posting Permissions

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