Creating like button with counter in Knack app using JavaScript

Hi 

I have made a news feed feature in my knack app to communicate recent development with my users. I want to make a like button using javascript which also display number of likes to keep users engaged and make things interesting.

One way I can think of is to create a connection to news post with another table and use count option in knack to display number of likes. But this has many drawbacks, it will have duplicate likes for start and I end up using many records just for likes because each like will create a new knack record. Its not a good way to use knack records since they charge for records. 

So I am thinking of making a number field in the same news feed table and create a like link in view. Then use javascript to add +1 with each click. But i don't know how to code this and also I don't know how avoid duplicate like. I need only 1 like per user. So if a user has already liked once it should allow him or her to like again. Creating an unlike button will be an extra step to make things more complex.

If anyone can point me in the right direction I will really appreciate. I wish knack has some build in social media features for things like this.

Thank You 

1 Like

Hi Ajay,

I thought of a relatively easy way to do it. Let me know if you are still trying to figure this out.

 

1 Like

I would be interest in knowing how you did it.

I have done this with a many to many connection field and then have Integromat either adding or removing the current user from the field when someone clicks.