I have a small bit of code that gets my images from smugmug. My problem is that I need that to finish before the rest of my code imports and fires. I have looked at other posts, but none seemed to fit my particular situation.
the code looks like:
(function($) {
$.fn.slideShow = function(options) {
var albumID = options.albumID;
var size = options.size || "Medium";
var delay = options.delay || 3000;
var div = this;
// Setup div
this.empty();
div.append("<ul></ul>");
$("ul:first").attr("title","fashion");
$("ul:first").addClass("stretch");
ul = div.find("ul");
$.smugmug.login.anonymously(function() {
$.smugmug.images.get({AlbumID: albumID, Heavy: 1}, function(images) {
$.each(images.Images, function() {
var url = this[size + "URL"];
console.log("Add img" + url);
ul.append("<li title=\"" + url + "\" /></li>");
});
});
});
};
})(jQuery);
I am calling it out of the HTMLand passing params with:
<script type="text/javascript">
nick = "hurleyhome";
$(function() {
$("#bg-images").slideShow({
size: "Medium",
albumID: "22516379",
delay: 5000
});
});
</script>
The scripts I need to run after this one does are, standard JS imports from a script tag.
Any help would be apreciated.
I was considering a $(window).load event, but not exactly sure how to implement it.
Thanks
Not sure I get the question, but it looks like you already have a success function, just get the script there, like so:
If you need to wait until all the images are actually loaded, you will have to attach a load() event to each image and do a check to see if they are all loaded or something similar..