关注是我的索引刀片
@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,但我被困在那里
答案 0 :(得分:0)
你将不得不以这种或那种方式使用javascript,否则我从未遇到过这种方式。然而,这是非常直截了当的。您可以使用data
属性轻松进行css选择器定位,然后使用一个简单的脚本根据需要注入您的值。这是一个很好的例子: