1

I'm using Laravel 5.0 and paginate along with the render() function in my view. Rather than go back to the top of the screen after I select the next page I want it to jump to #msgs. Here is some of my code:

<h1 class="centered" id="msgs">Announcements</h1>
    @foreach($messages->getCollection()->all() as $message)
        <div class="row">
            <div class="row">
                <div class="col-sm-9">
                    <h3>{{$message->title}}</h3>
                </div>
                <div class="col-sm-3">
                    <h4>From: {{$message->author_name}}</h4>
                </div>
            </div>
            <div class="row">
                <p>{{$message->text}}</p>
            </div>
        </div>
        <hr class="featurette-divider">
    @endforeach
    <div class="centered">
        {!! $messages->render() !!}
    </div>

I'm still getting a grasp on the flow of things in laravel so I'm not really sure what to do. I tried to use append->('#msgs') but realized that its appending an array in the parameters, not appending a path to the url. I there a simple way to achieve this without overriding anything?

4

1 回答 1

0

您可能想使用fragment()方法:

{!! $messages->fragment('msgs')->render() !!}

这是文档的链接:分页 - Laravel

于 2015-08-14T10:22:33.510 回答