Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- event.target.parentNode.parentNode.childNodes[1].textContent;
- event.target.parentNode.parentNode.childNodes[2].textContent;
- <article class="post col-md-6 ">
- <div class="media postforeach postborderleft">
- <div class="media-left media-top">
- </div>
- <div class="media-body">
- <header><h5 class="media-heading">{{ $post->title }}<i class="fa fa-angle-down pull-right " aria-hidden="true"></i></h5> </header>
- <p><i>{{ $post->body }}</i></p>
- <div class="info">
- Posted by {{ $post->user->name }} on {{ $post->created_at }}
- </div>
- @if (Auth::check())
- <div class="interaction">
- <a href="#" class="like">Like</a> |
- <a href="#" class="like">Dislike</a>
- @if (Auth::user() == $post->user)
- |
- <a href="#" class="edit">Edit</a> |
- <a href="{{ route('post.delete', ['post_id' => $post->id]) }}" class="like">Delete</a>
- @endif
- </div>
- @else
- <a href="{{ route('registeration') }}" class="like" style="color: red">Login to interract with posts!</a>
- @endif
- </div>
- </div>
- <br>
- </article>
- $('.post').find('.edit').on('click',function(event) {
- event.preventDefault();
- var postTitle = event.target.parentNode.parentNode.childNodes[1].textContent;
- var postBody = event.target.parentNode.parentNode.childNodes[2].textContent;
- $('#post-title').val(postTitle);
- $('#post-body').val(postBody);
- $('#edit-model').modal();
- });
- <header class="post-title">...</header>
- <p class="post-body>...</p>
- $('.post .edit').on('click', function(event) {
- var post = $(event.target).closest('.post');
- var postTitle = post.find('.post-title').text();
- var postBody = post.find('.post-body').text();
- // ...
- });
- var postBody = event.target.parentNode.parentNode.children[1].textContent;
- var postBody = event.target.parentNode.parentNode.childNodes[3].textContent;
- var $mediaBody = $(this).parents('.media-body'),
- postTitle = $mediaBody.find('.media-heading').text(),
- postBody = $mediaBody.find('p:first').text();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement