1. #1
    Ext User
    Join Date
    May 2008
    Posts
    2
    Vote Rating
    0
    Eki is on a distinguished road

      0  

    Default [2.2] Cannot use custom arguments in listener handler

    [2.2] Cannot use custom arguments in listener handler


    In the API documentation, addListener method accepts four arguments

    PHP Code:
    el.on('click'this.onClickthis, {
        
    singletrue,
        
    delay100,
        
    forumId4
    }); 
    The fourth argument can contain custom options (like forumID in the above example).
    But, when the handler function is called, the customs options are not passed.

    Example:

    PHP Code:
    Ext.onReady(function(){
        
        var 
    myButton = new Ext.Button({
                
    text'Click Me'
        
    });

        var 
    onClick = function (observableeoptions) {
            
    console.log(options);
        };

        
    myButton.on('click'onClickmyButton, {myArgument:'Custom'}); 
        
    myButton.render(document.body);
    }); 
    Firebug returns undefined for options

    This bugs comes from the Ext.util.Observable.prototype.fire method (Observable.js)

    PHP Code:
            fire : function(){
                var 
    ls this.listenersscopelen ls.length;
                if(
    len 0){
                    
    this.firing true;
                    var 
    args = Array.prototype.slice.call(arguments0);
                    for(var 
    0leni++){
                        var 
    ls[i];
                        if(
    l.fireFn.apply(l.scope||this.obj||windowarguments) === false){
                            
    this.firing false;
                            return 
    false;
                        }
                    }
                    
    this.firing false;
                }
                return 
    true;
            } 
    It should be

    PHP Code:
            fire : function(){
                var 
    ls this.listenersscopelen ls.length;
                if(
    len 0){
                    
    this.firing true;
                    var 
    args = Array.prototype.slice.call(arguments0);
                    for(var 
    0leni++){
                        var 
    ls[i];
                        
    args.push(l.options);   // options are appended to args array
                        
    if(l.fireFn.apply(l.scope||this.obj||windowargs) === false){  // args instead of arguments
                            
    this.firing false;
                            return 
    false;
                        }
                    }
                    
    this.firing false;
                }
                return 
    true;
            } 

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    89
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    There was a discussion on how to implement custom arguments for addListener. I think that in the end the option was removed, but the API docs weren't updated.

    You can accomplish the same with:

    Code:
    el.on('click', this.onClick.createDelegate(this, [4], true), this, {
        single: true,
        delay: 100
    });

  3. #3
    Ext User Blackhand's Avatar
    Join Date
    May 2008
    Posts
    42
    Vote Rating
    0
    Blackhand is on a distinguished road

      0  

    Default


    I just added a custom argument to a 'click' event handler today and it worked fine O_o.

  4. #4
    Ext User
    Join Date
    Feb 2009
    Location
    Craiova, Romania
    Posts
    41
    Vote Rating
    0
    sergiu079 is on a distinguished road

      0  

    Default Problem when firing an event

    Problem when firing an event


    Hello,
    I have this problem when firing a custom event, at the next line:

    this.fireEvent("myEvent", anObjectAsParameter);

    I receive the next error:

    l.fireFn has no properties
    (?)()(Object scope=Object options=Object)ext-all-debug.js (line 2124)
    apply()(Object 0=Object, function(), undefined)ext-base.js (line 7)
    fire()()ext-all-debug.js (line 2122)
    fireEvent()()
    ...............
    * if (l.fireFn.apply(l.scope || me.obj || window, args) === FALSE) {
    Any ideea?

  5. #5
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    89
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You added listener that isn't a function.

    ps. Next time, please start a new thread if you have a different problem.