How to add a Facebook “Like” button to an AJAX driven page

后端 未结 7 2502
醉酒成梦
醉酒成梦 2020-12-02 07:14

I have trawled the net and Stack Overflow and have not found an adequate answer to this question. Before I start the trial and error process of finding my own solution, I th

7条回答
  •  情深已故
    2020-12-02 07:20

    This is how I handled this situation when I ran into it - seems to work well.

    // Set Facebook Like Button with jQuery
    setFBLikeButtons = function (container,url,send,layout,width,show_faces,font) {
      // Set Default Args
      if(!send) { send = "false"; }
      if(!layout) { layout = "button_count"; }
      if(!width) { width = "100"; }
      if(!show_faces) { show_faces = "false"; }
      if(!font) { font = "arial"; }
    
      $(container).empty(); // Remove current like button
      $(container).html('');
      FB.XFBML.parse(); // This is the magical syrup
    }
    

提交回复
热议问题