Results 1 to 2 of 2

Thread: [4.1.0] Cannot toggleCls on document Element

  1. #1
    Sencha Premium Member
    Join Date
    Jun 2012
    Location
    Auckland, New Zealand
    Posts
    6

    Default Answered: [4.1.0] Cannot toggleCls on document Element

    Ext version tested:
    • Ext 4.1.0

    Browser versions tested against:

    • FF 13.0.1
    • IE 9.0
    • Chrome 19

    DOCTYPE tested against:
    • HTML5 DOCTYPE

    Description:
    • Ext.getDoc().toggleCls() throws a JavaScript error.

    Steps to reproduce the problem:
    • Get the document element
    • Call toggleCls on that element

    The result that was expected:
    • CSS class would be added/removed to the document element (<html>) in the same way it would be added/removed to other elements

    The result that occurs instead:
    • JavaScript error

    Test Case:

    Code:
    Ext.getDoc().toggleCls('yellow');
    See this URL for live test case: http://jsfiddle.net/wrumsby/KgGTp/

    Operating System:

    • Windows 7 Pro

  2. This is the expected behaviour. getDoc() refers to the document, not the html element.

    You'll want to use:

    Code:
    Ext.getBody().parent().toggleCls('foo');
    // or
    Ext.getDoc().first().toggleCls('foo');

  3. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,258
    Answers
    759

    Default

    This is the expected behaviour. getDoc() refers to the document, not the html element.

    You'll want to use:

    Code:
    Ext.getBody().parent().toggleCls('foo');
    // or
    Ext.getDoc().first().toggleCls('foo');
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Tags for this Thread

Posting Permissions

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