-1

Follow is my index blade

@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

When I click the title I wanted to open it in a modal instead of

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

I tried Ajax but I am stuck there

Bentaye
  • 9,403
  • 5
  • 32
  • 45
Heshanmax
  • 95
  • 1
  • 8

1 Answers1

0

You're going to have to use javascript one way or another, I have never come across a way otherwise. It is pretty straighforward, however. You can make use of data attributes for easy css selector targeting and then have a simple script that injects your values as needed. Here is a good example:

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