Fix 500 for mobile like without javascript
This commit is contained in:
parent
0c1483b16a
commit
9cc40af69c
2 changed files with 13 additions and 7 deletions
|
|
@ -63,18 +63,18 @@ $(document).ready(function(){
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
var link = $(this),
|
var link = $(this),
|
||||||
likeCounter = $(this).closest(".stream_element").find(".like-count"),
|
likeCounter = $(this).closest(".stream_element").find(".like-count"),
|
||||||
href = link.attr("href");
|
url = link.data("url");
|
||||||
|
|
||||||
if(!link.hasClass("loading")){
|
if(!link.hasClass("loading")){
|
||||||
if(link.hasClass('inactive')) {
|
if(link.hasClass('inactive')) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: href,
|
url: url,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
beforeSend: showLoader(link),
|
beforeSend: showLoader(link),
|
||||||
success: function(data){
|
success: function(data){
|
||||||
removeLoader(link);
|
removeLoader(link);
|
||||||
link.attr("href", href + "/" + data["id"]);
|
link.data("url", url + "/" + data.id);
|
||||||
|
|
||||||
if(likeCounter){
|
if(likeCounter){
|
||||||
likeCounter.text(parseInt(likeCounter.text(), 10) + 1);
|
likeCounter.text(parseInt(likeCounter.text(), 10) + 1);
|
||||||
|
|
@ -84,13 +84,13 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
else if(link.hasClass("active")){
|
else if(link.hasClass("active")){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: link.attr("href"),
|
url: url,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'DELETE',
|
type: 'DELETE',
|
||||||
beforeSend: showLoader(link),
|
beforeSend: showLoader(link),
|
||||||
complete: function(){
|
complete: function(){
|
||||||
removeLoader(link);
|
removeLoader(link);
|
||||||
link.attr("href", href.replace(/\/\d+$/, ''));
|
link.data("url", url.replace(/\/\d+$/, ""));
|
||||||
|
|
||||||
if(likeCounter){
|
if(likeCounter){
|
||||||
likeCounter.text(parseInt(likeCounter.text(), 10) - 1);
|
likeCounter.text(parseInt(likeCounter.text(), 10) - 1);
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,15 @@ module MobileHelper
|
||||||
|
|
||||||
def mobile_like_icon(post)
|
def mobile_like_icon(post)
|
||||||
if current_user && current_user.liked?(post)
|
if current_user && current_user.liked?(post)
|
||||||
link_to "", post_like_path(post.id, current_user.like_for(post).id), class: "entypo-heart like-action active"
|
link_to "",
|
||||||
|
"#",
|
||||||
|
data: {url: post_like_path(post.id, current_user.like_for(post).id)},
|
||||||
|
class: "entypo-heart like-action active"
|
||||||
else
|
else
|
||||||
link_to "", post_likes_path(post.id), class: "entypo-heart like-action inactive"
|
link_to "",
|
||||||
|
"#",
|
||||||
|
data: {url: post_likes_path(post.id)},
|
||||||
|
class: "entypo-heart like-action inactive"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue