From 7d1f9c5a3af338066735179fb4ae648e2f65d8a7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Fri, 12 Jul 2019 08:47:22 +1200 Subject: [PATCH] Most post like into a wrapper in the html --- app/assets/javascripts/likes.js | 6 +++--- app/views/photos/show.html.haml | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/likes.js b/app/assets/javascripts/likes.js index 5a03bedd5..cfa3ac94c 100644 --- a/app/assets/javascripts/likes.js +++ b/app/assets/javascripts/likes.js @@ -19,9 +19,9 @@ $(document).ready(function() { $('.photo-like').show(); $('.photo-like').on('ajax:success', function(event, data) { - var likeControl = $('.photo-like'); - - $('.like-count').text(data.description); + var likeControl = $('#photo-'+ data.id + ' .photo-like'); + console.log(data); + $('#photo-' + data.id + ' .like-count').text(data.description); if (data.liked_by_member) { likeControl.data('method', 'delete'); likeControl.attr('href', data.url); diff --git a/app/views/photos/show.html.haml b/app/views/photos/show.html.haml index 302d6cbaf..fb4e17cc2 100644 --- a/app/views/photos/show.html.haml +++ b/app/views/photos/show.html.haml @@ -11,12 +11,13 @@ %li.breadcrumb-item= link_to 'Photos', photos_path %li.breadcrumb-item.active= link_to @photo, @photo -.row +.row{id: "photo-#{@photo.id}"} .col-md-8 %h1.text-center.ellipsis=@photo.title %p.text-center = image_tag(@photo.fullsize_url, alt: @photo.title, class: 'rounded img-fluid shadow-sm') .col-md-4 + %p.text-center{ id: "photo-#{@photo.id}" } = render 'photos/actions', photo: @photo = link_to "View on Flickr", @photo.link_url, class: 'btn'