Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

javascript  Uncaught TypeError: Cannot read property 'dom' of null

Posted on 2014-09-30
6
Medium Priority
?
3,004 Views
Last Modified: 2014-10-01
hi experts

when i use a code something like this in my javascript

var customerImg = Ext.create('Ext.Img', {
    src: 'images/customer.png',  
    width: 14,
    height: 14,    
    margin : '0 0 0 5',
    //renderTo: Ext.getBody(),
    listeners: {
        afterrender: function(c) {
            Ext.create('Ext.tip.ToolTip', {
                target: c.getEl(),
                html: 'This   represents customer delays.'
            });
        }
    }
});


{
xtype: customerImg 
},

Open in new window



I end up getting error >> Uncaught TypeError: Cannot read property 'dom' of null


any idea whats wrong with the above code ?
When i comment out the above code the error goes away.

( I am using  Ext-js 4.2 )

thanks.
0
Comment
Question by:royjayd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 29

Accepted Solution

by:
Pravin Asar earned 2000 total points
ID: 40354335
View the working example @ https://fiddle.sencha.com/fiddle/b63

or look at the code below

Ext.define('MyImage.view.MyImg', {
    extend: 'Ext.Img',

    height: 201,
    renderTo: 'Ext.getBody(),',
    width: 400,
    src: 'http://www.sencha.com/img/20110215-feat-html5.png',
    title: 'Image Tooltip',

    initComponent: function() {
        var me = this;

        me.callParent(arguments);
    }

});

// @require @packageOverrides
Ext.Loader.setConfig({
    enabled: true
});


Ext.application({
    views: [
        'MyImg'
    ],
    name: 'MyImage',

    launch: function() {
        Ext.create('MyImage.view.MyImg', {renderTo: Ext.getBody()});
    }

});
0
 

Author Comment

by:royjayd
ID: 40354422
Thanks . My code works fine the first time. When I close the window and open the window second time that is when I get the cannot read property Dom of null error.

Anu idea why my code gives this error only on second time?
0
 

Author Closing Comment

by:royjayd
ID: 40354762
modified my code as per yours, seems fine now
thanks
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 29

Expert Comment

by:Pravin Asar
ID: 40355080
Thanks for the points.
0
 

Author Comment

by:royjayd
ID: 40355258
hi pravinasar

Will appreciate any help with my next question
http://www.experts-exchange.com/Programming/Languages/Java/Q_28529299.html

thanks.
0
 
LVL 29

Expert Comment

by:Pravin Asar
ID: 40356205
By the time, I looked at, it is deleted.

Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question