-1

跟随是我的索引刀片

@section('content')

<h1>Posts</h1>

<table class="table table-striped">
    <thead>
      <tr>
          <th></th>
        <th>Title</th>
        <th>Content</th>
        <th>Photo</th>
          <th>Comments</th>
        <th>Author</th>
        <th>Created @</th>
          <th>Edited @</th>
      </tr>
    </thead>
    <tbody>

    @if($posts)

        @foreach($posts as $key=>$post)
      <tr>
        <td>{{$key+1}}</td>
        <td><a href="{{route('home.post',$post->slug)}}" class="href">{{$post->title}}</a></td>
        <td>{{str_limit($post->content, $limit = 25)}}</td>
        <td><img src="{{$post->photo ? $post->photo->path : '/images/post_placeholder.png'}}" alt="" class="img-thumbnail" height="50px" width="100px;">
          <td><a href="{{route('admin.comments.show',$post->id)}}" class="href">View Comments</a></td>
        <td>{{$post->user->name}}</td>
        <td>{{$post->created_at->diffforHumans()}}</td>
        <td>{{$post->updated_at->diffforHumans()}}</td>
        <td><a class="btn btn-primary" href="{{route('admin.posts.edit', $post->id)}}">Edit</a></td>
      </tr>
      @endforeach
    @endif

    </tbody>
  </table>

<div class="row">
    <div class="col-sm-5 col-sm-offset-5">
        {{$posts->render()}}
    </div>
</div>
@endsection

当我单击标题时,我想以模式打开它而不是

{{route('home.post',$post->slug)}} 

我尝试了 Ajax,但我被困在那里

4

1 回答 1

0

您将不得不以一种或另一种方式使用 javascript,否则我从未遇到过其他方式。但是,它非常简单。您可以使用data属性来轻松定位 css 选择器,然后使用一个简单的脚本来根据需要注入您的值。这是一个很好的例子:

https://stackoverflow.com/a/34473803/320487

于 2017-06-17T03:52:08.137 回答