Question:
My code works perfectly when it comes to visual display at the page but the database adds a “1” after the earlier number of likes so if it is 1 from the start > next click makes the database show 11 (should be 2) and next click after that make it show 111 (should be 3).
Thank you very much but when I had no likes at all and clicked the like-button it stood “NA” on my page (“not aviable” i suppose?). Then when I gave another click it stood 3 in my database instead of 2. What can the reason be for this?
Now I changed the file type from text to number and then it worked in the database but not on the page, but I can probably solve that in some way.
This might be due to the fact that you are using a dynamic event handler for your button. I have also had some problems with dynamic event handlers when it involves wixData operations, which is why I’ll advise that you use a static onClick handler (export function) for the button instead.
And regarding NA showing up, make sure you set the text to 0 in the editor by default, that should solve it.
When I used this kod for removing a like it did only work at the page but the database added another like instead of removing one, so can you see the fault in this code?