1. #1
    Sencha User
    Join Date
    Jan 2012
    Posts
    113
    Vote Rating
    7
    Notepad123 is on a distinguished road

      0  

    Default Can I add/remove listeners of classes dynamicly

    Can I add/remove listeners of classes dynamicly


    Can I add/remove listeners of classes dynamically like I can with Objects.
    Can I , outside of the file where class is implemented, add new listener to this class or remove an existing one?

  2. #2
    Sencha User
    Join Date
    Nov 2010
    Posts
    395
    Vote Rating
    6
    gkatz is on a distinguished road

      0  

    Default


    Yes
    U can check the docs for specifics

  3. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Vote Rating
    847
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You can use on/un to add/remove listeners:

    Code:
    var comp = Ext.create('Ext.Component');
    
    comp.on('foo', someFn, comp);
    comp.un('foo', someFn);
    To remove the listener, you have to have access to the function so anonymous functions will not work. For that you would need to use the clearListeners which will clear all listeners. Having a reference to the function either by variable or off a scope.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #4
    Sencha User
    Join Date
    Jan 2012
    Posts
    113
    Vote Rating
    7
    Notepad123 is on a distinguished road

      0  

    Default


    I was thinking of adding/removing them to/from a class, not from an Object.So that every other project created from that class gets the listeners.And if this is possible would that also affect already created Object which were created before new listeners were introduced to a class?

Thread Participants: 2