This is the error that occurs:
Uncaught TypeError: Cannot read property 'replace' of undefined jquery.min.js:2
m.extend.camelCase jquery.min.js:2
m.extend.css jquery.min.js:3
(anonymous function) jquery.min.js:3
m.access jquery.min.js:3
m.fn.extend.css jquery.min.js:3
(anonymous function) tryingAgainTable.html:69
(anonymous function) tryingAgainTable.html:43
foreach tryingAgainTable.html:29
reduce tryingAgainTable.html:42
makeData.data tryingAgainTable.html:68
(anonymous function)
I create an element using jquery like this:
makeData["data"]({
"name": "Taxi Driver",
"style": {
"width": "71%"
},
"children": [
{
"el": "input",
"attributes": {
"name": "taxi_driver",
"id": "taxi_driver",
"type": "file"
},
"style": {
"border": "solid 1px red"
}
},
{
"el": "img",
"attributes": {
"id": "TaxiDriver",
"src": "#",
"alt": "your image"
}
}
]
});
The function is defined here:
var foreach=function(arr,fn)
{
for(var i=0;i<arr.length;i++)
{
fn(arr[i]);
}
};
var reduce=function(arr,base,fn)
{
foreach(arr,function(elem){
base=fn(base,elem);
});
return base;
}
makeData["data"]=function(obj)
{
var td=$('<td></td>').css(obj["style"]);
var td_out=reduce(obj.children,td,function(base,elem){
var element=$('<'+elem["el"]+'>').attr(elem["attributes"]).css(elem["style"]).appendTo(base);
});
console.log(td_out.get(0));
console.log(td_out.html());
return td_out;
}
The error is here in the jquery source is at line 346:
// Convert dashed to camelCase; used by the css and data modules
// Microsoft forgot to hump their vendor prefix (#9572)
camelCase: function( string ) {
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
}