Found this at MDC but how if I\'d wanted to add a private variable to the
var dataset = {
tables:{
customers:{
cols:[ /*here*/ ],
Private variables in javascript are done using the var keyword inside a closure. Only priviliged methods and attributes can access it. Here's the way to do it:
function dataset()
{
var private_stuff = 10; // private
this.foo = new function() { alert(private_stuff); } // priviliged
return {
tables:{
customers:{
cols:[ ],
rows:[ ]
},
orders:{
cols:[ ],
rows:[ ]
}
},
relations:{
0:{
parent:'customers',
child:'orders',
keyparent:'custid',
keychild:'orderid',
onetomany:true
}
}
}; // public
}
var d = new dataset;
alert(d.foo());