I'm currently modifying the Blog Dashlet to be a user dashlet that displays the blog posts from all sites of a member.I succeeded at this (the displaying part, I don't need the "create post" functionality) , but stumbled upon a few odds.If I bundle Ajax Requests in a for-loop, the loop terminates before the requests are completely processed.
loadPosts: function SiteBlog_loadPosts(sites)
{
for(var i = 0; i<sites.length; i++){
Alfresco.util.Ajax.request(
{
url: Alfresco.constants.PROXY_URI + "api/blog/site/" + sites[i] + "/blog/posts?pageSize=25",
successCallback:
{
fn: this.onPostsLoaded_Collector,
scope: this
},
failureCallback:
{
fn: this.onPostsLoadFailed,
scope: this
},
scope: this,
noReloadOnAuthFailure: true
});
}
},"sites" is an array of site names, the loop is the first step to collect posts from all the sites in "sites". I got the overall code working with a few detours, but the for-loop terminates, before the successcallback methods terminate (or run, for that matter). I don't know much about javascript, but how is that even possible? How can a loop terminate before the code within it? Is there a proper way to ensure that the loop does not terminate before the ajax requests?