Results 1 to 3 of 3

Thread: How to remove Listener from Controller?

  1. #1
    Sencha User
    Join Date
    Feb 2011
    Posts
    24
    Vote Rating
    3
      1  

    Default How to remove Listener from Controller?

    Hello,

    I'm using ExtJs 4.1.1a and I have no idea how to remove a Listener or to disable it for some time.

    I have a controller and I register some events in its init function like this:
    Code:
        this.control({ 
            'mypanel': {
                 beforeclose: this.onBeforeClose,
                 clickconstruction: this.onClick
            }
        });
    clickconstruction is fired in another controller with
    mypanel.fireEvent('clickconstruction');

    Now I am trying to remove the listener or to suspend the events but it does not work:
    Code:
    mypanel.un('clickconstruction', this.onClick);
    How do I remove or suspend correctly?

  2. #2
    Sencha User
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    347
    Vote Rating
    119
      1  

    Default

    Ext framework does not supply a method to unregister controller. One of the solution is using a flag. For example:
    Code:
        ...
        init: function(){
            this.control({ 
                'mypanel': {
                     beforeclose: this.onBeforeClose,
                     clickconstruction: this.onClick
                }
            });
        },
        onClick: function(){
            if (!this._suspendEvent){
                // do handling click event here
            }
        },
        suspendEvent: function(value){
            this._suspendEvent = value;
        },
        ...

  3. #3
    Sencha User
    Join Date
    Feb 2011
    Posts
    24
    Vote Rating
    3
      1  

    Default

    Thank you, I'm going to do it that way.

Posting Permissions

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