Can I run a JavaScript function AFTER Google Loader has run?

Posted by thatryan on Stack Overflow See other posts from Stack Overflow or by thatryan
Published on 2011-01-01T02:06:27Z Indexed on 2011/01/01 2:54 UTC
Read the original article Hit count: 232

Filed under:
|
|

I am loading Google API using google.load() and I need to process some of what is built by it, but I need to run the JavaScript after it has already completely loaded, is there a way to ensure that happens?

Here is how I build the list of images, I need to add an attribute to each img tag though, can't do that until after it is built right?

google.load("feeds", "1");

function initialize() {
    var feed = new google.feeds.Feed("myfeed.rss");

    feed.load(function(result) {
        if (!result.error) {             

            var container = document.getElementById("feed");

            for (var i = 0; i < result.feed.entries.length; i++) {               

               var entry = result.feed.entries[i];

               var entryTitle = entry.title;
               var entryContent = entry.content;

               imgContent = entryContent + "<p>"+entryTitle+"</p>";

               var div = document.createElement("div");
               div.className = "image";               

               div.innerHTML = imgContent;

               container.appendChild(div);
           }
       }
   });
}

google.setOnLoadCallback(initialize);

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery