-
Notifications
You must be signed in to change notification settings - Fork 13
Multiple click fix #2
Copy link
Copy link
Open
Description
Suggestion.
Generally you a class selector which primes all the the elements with the class="FB_reactions"
j$('.FB_reactions').facebookReactions({
postUrl: "/react/add/"
});
However, if we want to call on multiple individual elements like this (You may want multiple calls if you are doing something like Infinite scroll, or maybe dynamically adding stuff). ie.
j$('#MyReaction').facebookReactions...
j$('#MyReaction2').facebookReactions...
It gets funky, and will make multiple onClick calls (and thus ajax posts) when select one of the emotes from the pop-up (actually the number will be the number of elements below it on the page).
So I made a small change
I changed this line
$('.emoji').on("click",function (e) {
to
$('.emoji').off("click").on("click",function (e) {
which just removes any click handler it may have set before adding new one
In addition, I didn't want to create the 'faces' div over again, so I added this:
let faceAdded=0; // stop extra appends
(function($) {
....
if (!faceAdded++) <--- added this
$(_react_html).appendTo($('body'));
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels