I have a script that pulls json data and converts it to a readable format.
It is returning the error: Uncaught TypeError: undefined is not a function
on the line container.append($.nano(template, events[0]));
I have tried to find answers on stackoverflow which include:
I have done all of the above and have replicated the problem in this jsfiddle
You're calling nano incorrectly, it's not a method of jQuery. It should be like this (from the documentation ):
container.append(nano(nogig));
nano is on line 244 in the fiddle. I'm not sure where I'm not defining it.
On that line, you have this:
function nano(template, data) {
return template.replace(/\{([\w\.]*)\}/g, function (str, key) {
var keys = key.split("."),
v = data[keys.shift()];
for (var i = 0, l = keys.length; i < l; i++) v = v[keys[i]];
return (typeof v !== "undefined" && v !== null) ? v : "";
});
}
This is defined on the global scope, so change $.nano
to nano
.
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.