Results 1 to 3 of 3

Thread: How do I add a listener to the dom window object?

  1. #1
    Sencha Premium Member
    Join Date
    Aug 2012
    Posts
    78
    Answers
    3

    Question Answered: How do I add a listener to the dom window object?

    When I try this: (5 deprecated Ext.EventManager)
    Code:
    Ext.getWin().addListener('keydown', function(e, t) {
    ...
    });
    I get this error:
    • Uncaught TypeError: Cannot read property 'directEvents' of undefined ext-all-debug.js:13615
    • Ext.define.doAddListener ext-all-debug.js:13615
    • Ext.define.addListener ext-all-debug.js:13594
    • Ext.define.addDispatcherListener ext-all-debug.js:14376
    • Ext.define.doAddListener ext-all-debug.js:14360
    • doAddListener ext-all-debug.js:19791
    • Ext.define.changeListener ext-all-debug.js:14500
    • Ext.define.addListener ext-all-debug.js:14577
    • (anonymous function)

  2. I think I was calling getWin() too early. I moved it into Ext.onReady and it works without error calling getWin().

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791
    Answers
    585

    Default

    In ExtJS 4 I always used Ext.getDoc for this purpose, which seems to still work correctly. It isn't technically adding events to the window object but in practice the only event where that seemed to matter is resize, which is handled separately anyway.

    I wasn't able to reproduce the error you're seeing but I would agree that, if nothing else, the documentation should be clearer.

  4. #3
    Sencha Premium Member
    Join Date
    Aug 2012
    Posts
    78
    Answers
    3

    Default

    I think I was calling getWin() too early. I moved it into Ext.onReady and it works without error calling getWin().

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
  •