1

In my laravel project i use hashes in the url to keep track on selections of the user, so they are able to go back to a filter result. I dont want the page to refresh so I DONT UPDATE THE URL with Page=someid (except the hash) the response of the server looks like.

if ($request->ajax()) {      
    //The page I want to select posted with ajax
    $paginaId = $request->input('page');
    //some query like
    $query = Table::Query();
    //get 9 items
    $rooms= $query->paginate(9);
    //Return the response
    return Response::json(View::make('front.rooms.render', array('rooms' => $rooms))->render());
}

The $paginaId represents the selected pagination page. Everything works fine except one part. I cant set the current page of the pagination. I viewed the documentation but couldn't find any solutions.

2
  • I'm tried with your controller and with a jquery post, and it works fine. The pagination is inside template, and the current page will be setted automatically, if your render the pagination inside the template.
    – Iamzozo
    Sep 2, 2015 at 10:44
  • @lamzozo the question is how i can set the current page. (normaly its based ont he url page=pageid value. but i dont set it and want to set the selected page in my controller manualy. The code i have works but i need to set the page manualy. Sep 2, 2015 at 10:48

1 Answer 1

7

Try the following:

 $rooms = $query->paginate(9, ['*'], 'page', $paginaId);

In this case you can set $paginaId manualy

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.