setOnLoadCallback with jQuery

298 views
Skip to first unread message

soujiro0725

unread,
Apr 21, 2010, 2:31:02 AM4/21/10
to Google AJAX APIs
hi. I am trying to combine Ajax Feed API with a regular jQuery code.

By using Ajax Feed API, I am adding DOM elements to html. After that,
a normal jQuery code manipulates these DOM elements, which have
nothing to do with Ajax API.

But it seems that this jQuery part is ignored, and only added DOM
elements are shown. I am guessing that the problem is the timing of
execution.

For Ajax Feed API, "setOnLoadCallback" is to be used, then how can I
combine these two procedures?

//------------------code starts here---------------------------------
google.load("feeds", "1");
function feedLoaded(result) {
//
}

function OnLoad() {
//
feed.load(feedLoaded);
}
google.setOnLoadCallback(OnLoad);

jQuery(document).ready(function(){
jQuery(".jbgallery").jbgallery();
});
//-------------------code ends here-----------------------------------

--
You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group.
To post to this group, send email to google-ajax...@googlegroups.com.
To unsubscribe from this group, send email to google-ajax-searc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-ajax-search-api?hl=en.

Jeremy Geerdes

unread,
Apr 21, 2010, 6:26:40 AM4/21/10
to google-ajax...@googlegroups.com
Add the line jQuery(".jbgallery").jbgallery(); to the end of your OnLoad function, as below:

function OnLoad() {
feed.load(feedLoaded);
jQuery(".jbgallery").jbgallery();
}

If the jQuery line depends on the feed being loaded, you'll need to move it into feedLoaded, as below:

function feedLoaded(result){
// do stuff with the feed results
jQuery(".jbgallery").jbgallery();
}

Finally, isn't the jQuery code supposed to start with $? I.e., $(document).ready( and $(".jbgallery"). ?

Jeremy R. Geerdes
Effective website design & development
Des Moines, IA

For more information or a project quote:
http://jgeerdes.home.mchsi.com
jrge...@gmail.com

If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church!
Reply all
Reply to author
Forward
0 new messages