Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User mysticav's Avatar
    Join Date
    Mar 2007
    Location
    Mexico
    Posts
    474
    Vote Rating
    5
    mysticav is on a distinguished road

      1  

    Default How to avoid duplication of events in Controllers

    How to avoid duplication of events in Controllers


    Let say I define this same event on 2 different controllers:

    Code:
    this.control({
                '#foo':{
                    click: this.bar
                }
            });
    Normally, if the 2 controllers are already loaded, the event will be fired twice.

    My question is, How to avoid the duplicate registration of the same event ?

    I'm looking for an option like this:

    Code:
    this.control({
                '#foo':{
                    click: this.bar,
                    single: true
                }
            });

    This also helps for Inheritance of controllers, where you have listeners on the parent Controller, and you don't want those events to be registered for each child Controller.

    Any idea ? I'm sure other people had to deal with this before.
    Using Ext with cachefly
    Working on LAMPExt

  2. #2
    Touch Premium Member
    Join Date
    Nov 2010
    Location
    Chicago
    Posts
    1,294
    Vote Rating
    109
    LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light LesJ is a glorious beacon of light

      0  

    Default


    Did you try to return false from this.bar? I wonder if this would stop the other controller from processing the event... Is this even what you are trying to accomplish? I know you can stop an application event if you return false.

  3. #3
    Sencha User mysticav's Avatar
    Join Date
    Mar 2007
    Location
    Mexico
    Posts
    474
    Vote Rating
    5
    mysticav is on a distinguished road

      0  

    Default


    That won't resolve my problem because my controllers are loaded dynamically by demand, so whichever comes first should register the event and avoid duplication from other controllers that can also be loaded.

    Normally extJS eventBus supports duplication of events. They are organized something like this:

    example:

    click:
    controller1 #mygrid
    controller2 #mygrid

    What I would like to do is to tell eventBus not to register an event if the itemId already exists under the same handler (click).
    Using Ext with cachefly
    Working on LAMPExt

  4. #4
    Sencha User
    Join Date
    Oct 2011
    Location
    Vancouver, Canada
    Posts
    157
    Vote Rating
    14
    el_chief will become famous soon enough

      1  

    Default


    You should really init your controllers once only, preferably at startup.

    ExtJS is designed to have one instance of a controller, even if you have multiple instances of a view.

    Anyways, you can do something like this;

    Code:
    init: function(){
      if(this.inited){
        return;
      }
      this.inited = true;
    
      this.control(...);
    
    }

Thread Participants: 2