babiz / express-handlebars-paginate

BSD 3-Clause "New" or "Revised" License
7 stars 5 forks source link

Breaks the view #6

Closed mylastore closed 6 years ago

mylastore commented 6 years ago

I could see the pagination element but does not render the rest of the view. shot

mylastore commented 6 years ago

Now i formatted this way res.render('account/order-history', {orders: orders, pagination: { page: currentPage, limit: limit, totalRows: rows }});

and is not working either currently have the limit to 5 but does not seem to take effect

Is this suppose to be a completely separe view just for the pagination or it could be a combination for example on my orders saved and pagination all in one view and controller?

my app

babiz commented 6 years ago

@mylastore I think there is something wrong your code that renders overview orders. This module only is related to give pagination elements and does not relate to overview part. I see the pagination is coming so the module is working fine but there may be something wrong with your code.

mylastore commented 6 years ago

@babiz ah ok that's what I wanted to know, so I have to handle the rendering of the individual chunks of data of each age?

babiz commented 6 years ago

Basically, this is how I integrate this in the controllers.

res.render('contacts/index', {
            contacts: contacts.rows,
            pagination: {
                page: req.query.page,
                limit:req.query.limit,
                totalRows: contacts.count
            }
        });

Then iterate the contacts object in the view using loop command to show the view. SOmething like this

   {{#each contacts as |contact|}}
                    <tr>
                        <td>{{contact.name}}</td>
                        <td>{{contact.organization}}</td>
                        <td>{{contact.email}}</td>
                       ..............
......
mylastore commented 6 years ago

@babiz I try the page: req.query.page did not work for me but go it to work this way. Hope it helps someone else.

shop