adding to json property that may or may not exist yet
- by mmcgrail
let say i want to do this
var dasboard = {};
$('.check').click(function(){
$(this).toggleClass("active").siblings().slideToggle('slow', function() {
dashboard['pages']['pagename'][$(this).closest('li').attr("id")]['show'] = $(this).is(":hidden") ? 'collapsed' : 'expanded';
});
}
i get an error saying 'dashboard.pages is undefined'
is there away to dynamically add 'pages' and the children that follow without having to do the work of checking to see if it is defined first then if its not doing
dashboard['pages'] = {};
because sometimes they may already exist and I don't want to have to inspect the tree first i just want to build the branches as needed