简体   繁体   中英

Wordpress javascript conflict template and calendar

Wordpress javascript conflict template and calendar Wordpress javascript conflict template and calendar This error throws me

Uncaught TypeError: Cannot read property 'length' of undefined jquery.js:2
     v.extend.each jquery.js:2
     e.widget jquery.ui.widget.min.js:5
     (anonymous function) jquery.ui.tabs.min.js:5
     (anonymous function) jquery.ui.tabs.min.js:5

You are checking the length property of an identifier that has never been declared (ie is not a valid variable).
A construct along the lines of the following would remedy that issue:

Option 1:

if (typeof yourVariable !== "undefined") {
    var theLength = yourVariable.length;
} else {
    var theLength = 0;
}

Option 2:

var yourVariable = [];
if ( /* some condition */ ) {
    // reassign yourVariable;
}
var theLength = yourVariable.length;

My guess would be, that, as of now, your code looks like option two, without the first line, meaning that you declare the variable inside a conditional and check its length outside the conditional regardless of whether it was met.
But that's just a guess.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM