Refreshing facebook like button after swapping url with javascript is not working
-
20-06-2021 - |
Question
I have a problem where im using javascript to change the href of the facebook like button to change the url to a new link based on new ajax video content the user can load on the webpage. I want to make it so they can like each video based on the current one they are watching. The href is swapping out beautifully and i declared a FB.XFBML.parse(document.getElementById("fbyoutubelike")); to refresh the like button. However nothing happens and I'm not sure what to do anymore. Does anyone have a clue as to how this can be accomplished?
La solution
FB.XFBML.parse probably won’t re-render the tag if it sees the iframe is already there …
Instead of just manipulating the href attribute content, remove the existing like button tag (<fb:like>
or <div class="fb-like">
) from the DOM, insert a new one – and then call FB.XFBML.parse.