Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    110
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default [4.2.0 beta] Ext.get(window).getHeight() causes JS error

    [4.2.0 beta] Ext.get(window).getHeight() causes JS error


    REQUIRED INFORMATION

    Ext version tested:
    • Ext 4.2.0 beta
    Browser versions tested against:
    • Chrome
    • FireFox
    • IE9
    DOCTYPE tested against:
    • <!DOCTYPE html>
    Description:
    • Ext.get(window).getHeight() causes JS error. The same with Ext.fly. Uncaught TypeError: Cannot read property 'defaultView' of undefined
    Steps to reproduce the problem:
    • Click the buttons
    The result that was expected:
    • A window's height and width
    The result that occurs instead:
    • A JavaScript error occrus
    Test Case:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
        <title>Ext.get(window).getHeight() causes JS error</title>
    
        <link rel="stylesheet" href="../resources/css/ext-all.css" />
        
        <script src="../ext-all-debug.js"></script>
    
        <script>
            Ext.onReady(function () {
                Ext.create("Ext.button.Button", {
                    renderTo: Ext.getBody(),
                    text: "Ext.get(window).getHeight()",
                    handler: function () {
                        alert(Ext.get(window).getHeight());
                    }
                });
    
                Ext.create("Ext.button.Button", {
                    renderTo: Ext.getBody(),
                    text: "Ext.fly(window).getWidth()",
                    handler: function () {
                        alert(Ext.fly(window).getWidth());
                    }
                });
            });
        </script>
    </head>
    <body>
    
    </body>
    </html>
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,998
    Vote Rating
    649
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You're looking for

    Code:
    Ext.dom.Element.getViewSize();
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    110
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    Thank you, Evan.

    Does it mean that I should not use Ext.fly, Ext.get for a window?

    Well, there might be many other useful methods in Ext.dom.Element API. For example, I see that @Animal used the on method here (I see it is an old post, but anyway):
    http://www.sencha.com/forum/showthre...624#post507705
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,998
    Vote Rating
    649
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Windows can have events, but not dimensions.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    110
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    Well, the method that you suggested
    Code:
    Ext.dom.Element.getViewSize();
    use the getViewportWidth and getViewportHeight methods.

    They are:
    Code:
    /**
    * Retrieves the viewport height of the window.
    * @static
    * @return {Number} viewportHeight
    */
    getViewportHeight: function(){
        return window.innerHeight;
    },
    
    /**
    * Retrieves the viewport width of the window.
    * @static
    * @return {Number} viewportWidth
    */
    getViewportWidth: function() {
        return window.innerWidth;
    }
    Does it not return a window's dimensions?
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,998
    Vote Rating
    649
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Ok, perhaps that was a bad example. My point is that the window API is different from other elements, so you'd need to conditionalize every Element method to check if the element is a window.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Sencha User Daniil's Avatar
    Join Date
    Jun 2010
    Location
    Saint-Petersburg, Russia
    Posts
    975
    Vote Rating
    110
    Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all Daniil is a name known to all

      0  

    Default


    Ok, I got it. Thanks.
    Ext.NET - ASP.NET for Ext JS
    MVC and WebForms
    Examples | Twitter

Thread Participants: 1