1. #1
    Ext User
    Join Date
    Aug 2010
    Posts
    1
    Vote Rating
    0
    L33ch is on a distinguished road

      0  

    Default Intermittent incorrect border panel layout on Firefox - suggested fix

    Intermittent incorrect border panel layout on Firefox - suggested fix


    Hi,

    I've come across a problem where pages are intermittently displaying incorrectly on Firefox (3.6.8). I've tracked this down to clientWidth apparently reporting an incorrect value when rendering the Ext.Panel with a "border" layout. I say apparently, because what actually appears to be happening is that the script is occasionally running before the CSS has been applied (and so the reported clientWidth is actually correct - unexpected, but correct).

    I'm using the following script as a work-around. (I've only tested it on Firefox 3.6.)

    (function() {
    if (!Ext.isGecko){
    return;
    }

    // Extracted from \cvs\fproot\fp\shared\ext-2.2\source\core\EventManager.js
    // and then trimmed for Firefox only.

    var docReadyEvent, docReadyState = false;

    var initDocReady = function(){
    docReadyEvent = new Ext.util.Event();
    document.addEventListener("DOMContentLoaded", fireDocReady, false);
    Ext.lib.Event.on(window, "load", fireDocReady);
    };

    var fireDocReady = function(){
    if(!docReadyState && !delayDocReadyUntilCssHasLoaded()){
    docReadyState = true;
    Ext.isReady = true;
    document.removeEventListener("DOMContentLoaded", fireDocReady, false);
    if(docReadyEvent){
    docReadyEvent.fire();
    docReadyEvent.clearListeners();
    }
    }
    };

    var delayDocReadyUntilCssHasLoaded = function(){
    if(cssHasLoaded()){
    return false;
    }
    setTimeout(fireDocReady, 10);
    return true;
    };

    var cssHasLoaded = function(){
    var e;
    var sheets = document.styleSheets;
    if(!sheets || !sheets.length){
    return true;
    }
    for(var i = 0, limit = sheets.length; i < limit; ++i){
    var sheet = sheets[i];
    try{
    if(!sheet.cssRules){
    return false;
    }
    }
    catch (e){
    return false;
    }
    }
    return true;
    };

    Ext.onReady = Ext.EventManager.onDocumentReady = function(fn, scope, options){
    if(docReadyState){ // if it already fired
    docReadyEvent.addListener(fn, scope, options);
    docReadyEvent.fire();
    docReadyEvent.clearListeners();
    return;
    }
    if(!docReadyEvent){
    initDocReady();
    }
    options = options || {};
    if(!options.delay){
    options.delay = 1;
    }
    docReadyEvent.addListener(fn, scope, options);
    };
    })();


    I don't know if this has been documented somewhere else or not. If there's a better solution, then please let me know. No doubt someone will point out a simple config flag somewhere that solves the problem...

    Cheers,
    - Lee
    Last edited by L33ch; 24 Aug 2010 at 1:49 PM. Reason: Fix to script.

Similar Threads

  1. Replies: 3
    Last Post: 22 Jun 2009, 6:03 AM
  2. [2.2] Border layout with incorrect layout
    By gnomie in forum Ext 2.x: Help & Discussion
    Replies: 8
    Last Post: 10 Aug 2008, 11:19 AM
  3. [2.2] Border layout with incorrect layout
    By gnomie in forum Ext 2.x: Bugs
    Replies: 6
    Last Post: 9 Aug 2008, 9:44 AM
  4. Replies: 12
    Last Post: 19 Apr 2008, 6:24 AM
  5. Ext.BasicForm.afterAction Suggested Fix
    By vtswingkid in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 9 Apr 2007, 1:35 PM

Tags for this Thread