Results 1 to 5 of 5

Thread: [FIXED][3.0 Core svn310] Element

    Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member stever's Avatar
    Join Date
    Mar 2007
    Posts
    1,408
    Vote Rating
    9
      0  

    Default [FIXED] [3.0 Core svn310] Element

    Back to nitpicking (sorry). The fix in v310 for fly elements is to force them into real elements, at which point, why use fly elements at all?

    Code:
        focus : function(defer) {
            var me = this;
            try{
                if(!isNaN(defer)){
                    me.focus.defer(defer, Ext.get(me.dom));
                }else{
                    me.dom.focus();
                }
            }catch(e){}
            return me;
        }
    perhaps would be better as:

    Code:
        focus : function(defer,dom) {
            var me=this;
            dom = dom || me.dom;    
            try{
                if(!isNaN(defer)){
                    me.focus.defer(defer, me,[null,dom]);
                }else{
                    dom.focus();
                }
            }catch(e){}
            return me;
        }
    Though I wouldn't put the new second parameter in the docs...

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,584
    Vote Rating
    873
      0  

    Default

    Because in some cases it is required, for example without that fix:

    Code:
    Ext.onReady(function(){
        var bd = Ext.getBody();
        
        bd.createChild({
            id: 'text1',
            tag: 'input',
            type: 'text'
        });
        
        bd.createChild({
            id: 'text2',
            tag: 'input',
            type: 'text'
        });
        
        Ext.fly('text1').focus(2000);
        Ext.fly('text2').addClass('foo');
    });
    Evan Trimboli
    Twitter - @evantrimboli

  3. #3
    Sencha User mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
      0  

    Default

    just a heads up:
    Code:
    isNaN('') // returns false
    try this instead:
    Code:
    focus: function(defer) {
        var me = this;
        try {
            if (Number(defer)) { // defer > 0
                me.focus.defer(defer, Ext.get(me.dom));
            } else {
                me.dom.focus();
            }
        } catch(e) {}
        return me;
    }

  4. #4
    Ext JS Premium Member stever's Avatar
    Join Date
    Mar 2007
    Posts
    1,408
    Vote Rating
    9
      0  

    Default

    Quote Originally Posted by evant View Post
    Because in some cases it is required, for example without that fix:
    I didn't say it didn't need to be fixed. Only that it had a side effect of creating a real Element object when it didn't need to. I thought using fly() was a way to avoid that. There are other ways to skin this cat, and I posted one, another would be to use a private deferfocus fn, and others out there I'm sure.

    I'm just not a fan of having unintended side effects. In your example, the user had two calls to fly (and not get so they didn't want the creation of new Element objects), yet one got created.

    I did preface the post with an apology for nitpicking!

  5. #5
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,584
    Vote Rating
    873
      0  

    Default

    Modified to appease the nitpickers along with a few others.
    Evan Trimboli
    Twitter - @evantrimboli

Posting Permissions

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