Just starting out with javascript and I'm a bit confused about how to solve a particular issue. Hopefully, the example below can help explain my situation:
let tasks = {
'04-23-2018' : '<a href="http://tympanus.net/codrops/2012/11/23/three-script-updates/">Three Script Updates</a>',
'04-21-2018' : '<a href="http://tympanus.net/codrops/2012/11/21/adaptive-thumbnail-pile-effect-with-automatic-grouping/">Adaptive Thumbnail Pile Effect with Automatic Grouping</a>',
'04-20-2018' : '<a href="http://tympanus.net/codrops/2012/11/20/learning-principles-for-improving-your-css/">Learning Principles for Improving Your CSS</a>',
'04-19-2018' : '<a href="http://tympanus.net/codrops/2012/11/19/responsive-css-timeline-with-3d-effect/">Responsive CSS Timeline with 3D Effect</a>'
};
$.get( "/api/tasks").done(function( data ) {
tasks["04-26-2018"] = '<a href="http://tympanus.net/codrops/2012/04/30/fluid-css3-slideshow-with-parallax-effect/">BING BONG BONG SSSSS</a><a href="http://tympanus.net/codrops/2012/04/30/im-creator-giveaway/">IM Creator Giveaway</a>';
});
I'm currently debugging the above get request as I am testing some variables to understand the asynchronous nature of get requests.
Later on in my script, I have the following segment of code:
let calendar = $calendar.calendario({
onTaskClick : function( $el, $contentEl, taskProperties ) {
if( $contentEl.length > 0 ) {
showTasks( $contentEl, taskProperties );
}
},
caldata : tasks,
displayWeekAbbr : true
});
I assigned the variable "tasks" to caldata.
However, it seems that caldata only includes the initial objects - not the key value pair I added within the done function of the get request...
How can I ensure that the collected data is returned before declaring let calendar? I attempted declaring let calendar after setting the tasks["04-26-2018"] key but this introduced issues as other functions within the script also require calendar?? I'm feeling quite lost and would appreciate any guidance on this matter.
Thank you.