javascript - How to call a function only after page has finished loading and after another function has been called -
javascript - How to call a function only after page has finished loading and after another function has been called -
so i'm using http://kenwheeler.github.io/slick/ , http://instafeedjs.com/ , i'm trying create carousel slider based on instagram feed, problem i'm running since content in #instafeed
dynamically loaded, keeps returning undefined in javascript code because hasn't been injected dom yet. how load code after function userfeed.run()
has been called , instagram photos have been injected?
$(window).bind("load", function() { var userfeed = new instafeed({ get: 'user', userid: 434846375, accesstoken: '#############################', limit: 5, template: '<div style="display: inline-block;"><img src="{{image}}" /></div>' }); // userfeed.run(); $.when(userfeed.run()).done(function() { $('.your-class').slick({ arrows:true }); var array = $( "#instafeed" ).toarray(); for(i = 0; < 5; ++i) { alert(array[i]); //$('.your-class').slickadd(array[i]); } }); });
unfortunately appears userfeed.run()
homecoming true immediately, , need homecoming deferred/promise work $.when
.
you can howerver add together after
callback instafeed initialization should want:
var userfeed = new instafeed({ get: 'user', userid: 434846375, accesstoken: '#############################', limit: 5, template: '<div style="display: inline-block;"><img src="{{image}}" /></div>', after: function() { // images added dom, stuff here } });
javascript jquery
Comments
Post a Comment