AlexGG wrote "For example, on page load I want to show just 10 elements, if user clicks "load more" the list should have 20 elements... "
As I understand that, Alex was not asking to only show the next 10 items (items 11-20) , but the previous 10 items plus the next 10 items (all items 1-20). This would enable the list to grow with each "load more", incurring only a 10 item database hit each time.
Yurii advised the following code:
=========
//Note: you should to replace "mobilelistitem_3" with your list item name.
$('[dsrefid="mobilelistitem_3"]').not('[_tmpl="true"]').attr("dsrefid", "");
var skip = parseInt(localStorage.getItem('skip'));
var limit = parseInt(localStorage.getItem('limit'));
var total = parseInt(localStorage.getItem('total'));
if (limit + skip < total) {
localStorage.setItem('skip', limit + skip);
restservice1.execute({});
if (limit + skip == total - limit) {
Appery('nextButton').hide();
};
}
=========
Presumably this solution was intended to retain the results of the previous query (items 1-10) and add to it the results of the next query (items 11-20).
When I did this (and yes I replaced the List Item with mine), the list only showed the next 10 items (items 11-20). That is the same behavior as it would have had without the addition of :
$('[dsrefid="mobilelistitem_3"]').not('[_tmpl="true"]').attr("dsrefid", "");
(which by the way, what does this do exactly?)
Did I misunderstand the intent of Yurii's code? If not, what might I be doing wrong?