dimanche 5 février 2017

cybercog/laravel-likeable action problems

I going to implement a likeable system into my current laravel project system. The package i implement is this github

i follow the documentation and every thing is fine, but they is a problem that i need to store the like into database only if users clicked the button, but in the documentation it is only using

$article->like();

i trying to limit it using JavaScript to checking only if users clicked then the action will perform but failed, as long as i open the page and clicked any button, they will auto store the like into database. Is there any solution?

My javascript

@foreach($posts as $post)

    var like = document.getElementById("like");
    var dislike = document.getElementById("dislike");

    like.onclick = function(){
        like.style.color = "blue";
        dislike.style.color = "grey";
        $post->like();
    };

    dislike.onclick = function(){
        dislike.style.color = "red";
        like.style.color = "grey";
        $post->dislike();
    };

@endforeach



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2l9EOdR
via IFTTT

Aucun commentaire:

Enregistrer un commentaire