Solved

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

Posted on 2014-09-30
6
2,459 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
  • 3
  • 3
6 Comments
 
LVL 28

Accepted Solution

by:
Pravin Asar earned 500 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 28

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 28

Expert Comment

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

Thanks
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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…

774 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