Reputation: 4276
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
Upvotes: 0
Views: 719
Reputation: 13799
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
.
Upvotes: 1
Reputation: 12431
You're calling nano incorrectly, it's not a method of jQuery. It should be like this (from the documentation):
container.append(nano(nogig));
Upvotes: 2