Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: Cannot read property 'nodeName' of undefined

this problem appears only in joomla -

im trying to use the contentflow plugin with my joomla site

this is the plugin site - http://www.jacksasylum.eu/ContentFlow/

this is my site - http://2-dweb.com/RND/

as you can see it doesnt work - it just stays on the loading phase forever

upon closer inspection i can see that there is a problem with this code:

  if (this.content.nodeName == "IMG") {
    CFobj._imagesToLoad++;

    var foobar = function () { 
        CFobj._imagesToLoad--;
        this.image = this.content;
        this.setImageFormat(this.image);
        if ( CFobj.conf.reflectionHeight > 0) {
            this.addReflection();
        }
        this.initClick();
        CFobj._addItemCueProcess(true);
    }.bind(this);

    if (this.content.complete && this.content.width > 0)
        window.setTimeout(foobar, 100);
    else if (this.Browser.IE && !this.content.onload) {
        var self = this;
        var t = window.setInterval( function () {
            if (self.content.complete && self.content.width > 0) {
                window.clearInterval(t);
                foobar();
            }
        }, 10);
    }
    else
        this.content.onload = window.setTimeout(foobar, 100);
}
else {
    this.initClick();
    CFobj._addItemCueProcess(true);
}

};

with the first line - it says "Uncaught TypeError: Cannot read property 'nodeName' of undefined "

but this thing works on my desktop html file and on the plugin site it self!

why doesnt it work on my joomla site? its not a conflict thing - im using no-conflict and i have other jquery plugins that work

update:

rob w helped me with this error: "Change the first line to if (this.content && this.content.nodeName == "IMG") {. That solves the problem"

and it did, but now another error appears:

  initClick: function () {
        var cItem = this.clickItem;
        this[this._activeElement].addEvent('click', cItem, false);
    },

the error - Uncaught TypeError: Cannot call method 'addEvent' of undefined

like image 657
David Nelband Avatar asked Feb 20 '12 14:02

David Nelband


2 Answers

As the error explains "Uncaught TypeError: Cannot read property 'nodeName' of undefined " The element is not available when the script tries to access it. You can solve this in two ways.

  • Try to wrap to code with a document.ready.
  • You can check whether the element is available before accessing it. To get this done use a if clause.
like image 51
Techie Avatar answered Nov 06 '22 20:11

Techie


Solved this.

I am using bootstrap.css version 3.3.7 and bootstrap.js version 4.0.0.

By changing bootstrap.js to version 3.3.7 my issue got resolved!!!

like image 3
harbrinder_singh Avatar answered Nov 06 '22 20:11

harbrinder_singh