I don’t know how to ask this question at all. in case some one don’t understand this, i am sorry. thing is, i have the object, and i am looping that using each function, when i get sub object (internal obejct), i would like to assign back to the same each function for that, what is the good idea?
look my issue:
myObject:
var xploreMaps = {
radious:55,
stroke:5,strokeColor:'#fff',
opacity:0.8,fontSize:13,line:10,
cGtext:{
length:5,
lineColor:'#579549',
prop:{
0:{link:'catalogs .html',color:'#7a5967',text:'Catalogs',
subLink:{0:{link:'SEO_SMM.html',color:'#4e4b69',text:'SEO/SMM',align:'top'},1:{link:'site_analytics.html',color:'#545454',text:'Site analytics',align:'btm'}}},
1:{link:'socialmedia.html',color:'#1e9ead',text:'Innovation'},
2:{link:'loyalty .html',color:'#8fad34',text:'Ideation'},
3:{link:'promotions .html',color:'#563b64',text:'Promotions'},
4:{link:'implementations.html',color:'#2c6566',text:'Implementations',
subLink:{0:{link:'integrating.html',color:'#4c4a66',text:'Integrating',align:'top'},1:{link:'payment.html',color:'#948048',text:'Payment',align:'btm'}}}
}
}
}
var object = xploreMaps[id].prop || 'i need subLink';
myfunction:
$.each(object, function (n,d) {
var Color = this.color,link = this.link,text=this.text,**subLink** = this.subLink || '';
// if the sublink there, i need to put back to each, and do the same stuff, what i do for it's parent object.
var myTimeout = setTimeout(function(){
redSubCircles.push(paper.path("M"+x +" "+y)
.attr({stroke:brdColor})
.animate({path:"M"+(x-((stroke/2)+(n*((radious*2)+stroke+line)))) +" "+y+'l'+(-line)+' 0'},1000,
function(){
var c = paper.circle((x-(radious+stroke+line) - n*((radious*2)+stroke+line)),y,radious)
.attr({
stroke:strokeCl,
'stroke-width':stroke,
opacity:opacity,
fill:Color,
href:link
});
var p = paper.text((x-(radious+stroke+line) - n*((radious*2)+stroke+line)),y,text)
.attr({fill:strokeCl,'font-size':fSize,href:link})
redSubCircles.push(c,p)//push to set;-
}));
},1000*n)
} )
if i am wrong, i am sorry. please advice me the right way.
Perhaps a while loop and a temporary array would help you.
Add your initial items to the temporary array
Call the function while there are items in your temporary array
Every time you encounter a sub link push it onto the temporary array you’re iterating it through. Temporary array gets bigger, and continues to run.
Every time you’ve completed an item, remove it. Temporaray array gets smaller, and eventually reaches zero – completing your loop.
You’ll need while, push, and splice to remove items from your array.
Here’s a standalone example of this in action, and a demo here