js to populate slider

This commit is contained in:
Sanj 2011-10-06 01:17:58 +05:30
parent c2058c6bd5
commit 514198a884

View File

@ -3,7 +3,21 @@ $(function() {
e.preventDefault(); e.preventDefault();
var q = $('#search').val(); var q = $('#search').val();
$.getJSON("/search/", {'q': q}, function(data) { $.getJSON("/search/", {'q': q}, function(data) {
console.log(data); var $container = $('.overview');
$container.empty();
for (var i=0; i<data.length; i++) {
var $li = getLi(data[i]);
$li.appendTo($container);
}
}); });
}); });
}); });
function getLi(image) {
var $li = $('<li />').data("data", image).click(function() {
var data = $(this).data("data");
alert(JSON.stringify(data));
});
var $img = $('<img />').attr("src", image.Thumbnail.Url).appendTo($li);
return $li;
}