Paging with Jquery

Asked

Viewed 526 times

1

I searched some sites and here in the stack looking for how to create a pagination script with the following features:

  • The elements are collected in the HTML
  • I can use the function at any time and in any element, just by invoking it and passing the parameters (such as number of elements per page, which element should be paginated, which parent element of the pagination, etc)

In this case, I did not find any question/answer that could fully clarify these points, nor did I find a good API, tried the easyPaginate, but it is generating errors in jquery when used. Any suggestion of API or script for this pagination ?

    <div id="pagination">
        <div>
            <figure></figure>
            <figure></figure>
            <figure></figure>
            <figure></figure>
            <figure></figure>
            <figure></figure>
            <figure></figure>
        </div>
    </div>

A script that can be used in a simple way, like the easyPaginate itself I mentioned above

$("#pagination").paginar({
   elemento:figure,
   elementosporpagina:3
});

1 answer

1


Use the elements this way

<div id="pagination">
            <figure><img src="https://fakeimg.pl/50/"></figure>
            <figure><img src="https://fakeimg.pl/50/"></figure>
            <figure><img src="https://fakeimg.pl/50/"></figure>
            <figure><img src="https://fakeimg.pl/50/"></figure>
            <figure><img src="https://fakeimg.pl/50/"></figure>
            <figure><img src="https://fakeimg.pl/50/"></figure>
            <figure><img src="https://fakeimg.pl/50/"></figure>
    </div>

Jquery.paginate

After linking the library (js and css), add

$('#pagination').paginate({ 'perPage': 5 });
$('#pagination').paginate({ 'scope': $('figure') });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.