У меня есть сайт, который будет содержать 100s объектов, которые имеют следующий вид:Показать 10 Jquery объектов в то время
function Products (type, title, description, cost, image){
this.type = type;
this.title = title;
this.description = description;
this.cost = cost;
this.image = image;
this.displayInfo = function(){
var info ="<div class='p-image'>";
info += this.image + "</div><div class='p-title'>";
info += this.title + "</div><div class='p-cost'>";
info += "Online Product Cost: $" + this.cost + "</div><div class='p-desc'>";
info += "<strong>DESCRIPTION:</strong> " + this.description + "</div>";
return info;
}
}
// define an array to store products
var product_list = [];
var im = "<img src='http://ecx.images-amazon.com/images/I/911wQX4ahaL._SL1500_.jpg' id = 'image'>";
var desc = "<br><span style = 'font-weight: bold; padding-top: 10px;'>Developer: </span>Teyon<br> <span style = 'font-weight: bold;'>Platforms: </span>PS3, WIN, X360<br> <span style = 'font-weight: bold;'>Release Date: </span>2013</br><span id = 'para'> Sequel to Heavy Fire: Afghanistan, in which soldiers are sent after a captured spy who holds the plans to a secret Iranian nuclear weapons facility.</span>";
var product = new Products('v fps win xbone ps3','Heavy Fire: Shattered Spear',desc, 10.00, im);
product_list.push(product);
var im = "<img src='http://upload.wikimedia.org/wikipedia/en/c/c5/AliensColonialMarinesBox.png' id = 'image'>";
var desc = "<br><span style = 'font-weight: bold;'>Developer: </span>Gearbox Software<br> <span style = 'font-weight: bold;'>Platforms: </span>PS3, WIN, X360<br> <span style = 'font-weight: bold;'>Release Date: </span>2013</br><span id = 'para'>True sequel to James Cameron's film, the story of Aliens: Colonial Marines takes place nearly 17 weeks after the events of Alien 3 and almost 199 years prior to the events of Alien Resurrection, as the cryotubes containing Ellen Ripley, Corporal Hicks, Newt, and the android Bishop had ejected from the Sulaco. </span>";
product_list.push(new Products('v fps','Aliens: Colonial Marines',desc, 10.00, im));
displayProducts();
function displayProducts() {
for (var i=0; i<product_list.length; i++){
//product_list[i].type can determine which are chosen
var divrow = "<div class='list "+ product_list[i].type + "' data-index='" +i+ "' >";
divrow += product_list[i].displayInfo() + "</div>"
$('#main-list').append(divrow);
//tried append to '#list' and '.list' but didn't work either so made main-list div
}
}
........
Когда они показывают, как только загрузка страницы - это все сразу. Таким образом, «высота» моей страницы огромна. Я хочу, чтобы список упал с 100 до 10 показов за раз. Подобно тому, как Google показывает свой веб-сайт:
Я никогда не делал эту версию .show(), прежде чем это мне было интересно, как это сделать. Я просто хочу, чтобы они динамически обновлялись на странице, потому что у меня есть таблица корзины покупок на той же странице. Любые идеи или предложения?
Мой сайт до сих пор выглядит следующим образом:
быстрый поиск дает [этот пейджинговый плагин] (h TTPS: //plugins.jquery.com/paging/). Там более простой [здесь] (http://flaviusmatis.github.io/simplePagination.js/). –
Я ищу программу самостоятельно. Я думал, что для этого вам нужна функция show.show() hide? – narue1992
Я вижу вашу вторую ссылку. Я проверю это – narue1992