Created
July 15, 2014 01:35
-
-
Save elyseholladay/e0de193f23505440a811 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
var animals = []; | |
$.getJSON( "https://mks-frontend-gallery.herokuapp.com/", function( json ) { | |
for (var i in json) { | |
$(".gallery").append("<div class='large-4 small-6 columns " + json[i].animals.join(" ") + "'><img src=" + json[i].url + "></div>"); | |
} | |
var ids = []; | |
$.each( json, function ( key, val ) { | |
for (var x = 0; x < val.animals.length; x++) { | |
ids.push( | |
val.animals[x] | |
); | |
} | |
$.unique(ids); | |
}); | |
for (i in ids) { | |
$(".filters").append("<div class='filter-button individual button active' id='" + ids[i] + "'>" + ids[i]+ "</div>"); | |
} | |
console.log(ids); | |
}).done(function(){ | |
console.log("done") | |
$('.filter-button').click(function(){ | |
$(this).toggleClass("active"); | |
$("." + this.id).fadeToggle(1000, "swing", function(){console.log("fade is done")}); | |
}); | |
}).fail(function(){ | |
console.log("fail") | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment