I am using paging with my NodeJS page.
In ?page=4 , I edit a form, and save it. But then I redirected to home. How can I handle this?
I am writing return res.redirect('/products/') after saving the product.
exports.update = function(req, res){
var product = req.product
product = _.extend(product, req.body)
product.save(function(err) {
if (!err) {
//here, I also tried res.redirect('back') but it stay in the same page
return res.redirect('/products')
}
res.render('products/edit', {
title: 'Edit Product',
product: product,
errors: err.errors
})
})
}
The template is:
if (pages > 1)
.pagination
ul
!= createPagination(pages, page)
createPagination function is from view-helpers module.