如何使用jquery

时间:2016-07-19 06:59:45

标签: javascript php jquery twitter-bootstrap bootstrap-modal

我已经制作了一个显示用户帖子的个人资料页面,用户可以执行功能删除或编辑帖子。但是,

当我点击任何帖子上的编辑帖子时,只会在模态中提取第一篇文章的内容。

我的js代码:

$('.dropdown-menu').find('.edit').on('click', function(e) {
  e.preventDefault();

  var postbody = $('#fetch').find('p').text();

  $('#post-body').val(postbody);
  $('#edit-modal').modal();
});

我的观看代码:

@foreach($posts as $post) @if(Auth::user()== $post->user)

<div class="panel panel-default">
  <div class="panel-heading">
    <div class="row">
      <section class="col-md-2 col-xs-2">
        <img id="imagesize2" src="images/g.jpg" class="img-circle" data- action="zoom" />

      </section>
      <section class="col-md-5 col-xs-offset-1 col-xs-5">
        <a id="alink13" href=""><h5 id="alink14">{{$post->user->firstname}}</h5> </a>
        <p>on {{$post->created_at}}</p>
      </section>
      <section class="col-md-offset-3 col-md-2 col-xs-4 col-lg-offset-1">
        <div class="btn-group">
          <button id="btnclr4" type="button" class="btn btn-default dropdown- toggle" data-toggle="dropdown" aria-expanded="false"><span class="glyphicon  glyphicon-chevron-down"></span>
          </button>
          @if(Auth::user()==$post->user)
          <ul id="remove" class="dropdown-menu" role="menu">
            <a id="remove2" href="{{route('post.delete',['post_id' => $post->id])}}">
              <li role="presentation">Remove This Post</li>
            </a>
            <a href="" class="edit">
              <li role="presentation">Edit This Post</li>
            </a>
          </ul>
          @endif


      </section>
      </div>
    </div>
    <div class="panel-content">
      <div class="row" id="fetch">
        <section class="col-md-12">
          <p>{{$post->body}}</p>
        </section>
      </div>
    </div>

0 个答案:

没有答案