diff --git a/lib/views/event/event.haml b/lib/views/event/event.haml index d907d17..854f334 100644 --- a/lib/views/event/event.haml +++ b/lib/views/event/event.haml @@ -19,7 +19,7 @@ -if current_user.following?(event.user) %p.btn.btn-primary.following-btn= "Following #{event.user.user_name}" -else - %a.btn.btn-warning.follow-btn{id: "followed-user-#{event.user.id}"}= "Follow #{event.user.user_name}" + %a.btn.btn-warning.follow-btn{id: "followed-user-#{event.user.user_name}-#{event.user.id}"}= "Follow #{event.user.user_name}" .row %h4= "comments" %hr @@ -45,7 +45,8 @@ $('.follow-btn').click(function(e) { var obj = event.target; - var followed_user_id = $(obj).attr('id').split('-')[2]; + var followed_user_id = $(obj).attr('id').split('-')[3]; + var followed_username = $(obj).attr('id').split('-')[2]; $.ajax({ type: "POST", url: '/api/update/user/follow', @@ -54,8 +55,8 @@ }).done(function( msg ) { if (msg == "true") { $('.follow-btn').remove() - $('#follow-tray').prepend("
Successfully following " + followed_username + "
") - $('#follow-tray').append("

Following #{event.user.user_name}

") + $('#follow-tray').prepend("
Successfully following " + followed_username + "
") + $('#follow-tray').append("

Following #{event.user.user_name}

") } else { console.log("failed to follow user") } diff --git a/lib/views/user/following.haml b/lib/views/user/following.haml index b5ea31e..eae59f0 100644 --- a/lib/views/user/following.haml +++ b/lib/views/user/following.haml @@ -36,7 +36,7 @@ }).done(function( msg ) { if (msg == "true") { $("#following-user-" + following_user_id).remove(); - $('#following-row').prepend("
Successfully unfollowed " + followed_username + "
") + $('#following-row').prepend("
Successfully unfollowed " + followed_username + "
") } else { console.log("failed to unfollow user") }