0

I have a button that should open up a popup for a Facebook invite window but the button reloads the page. How to I handle this click so that it returns false? I.e. What is the syntactically correct way of doing this?

<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
$(function(){
     $("a#invite_fb_friends").click(function() {
         FB.init({
             appId:'257395654482349',
             cookie:false,
             status:true
         });
         FB.ui({
             method: 'apprequests',
            message: 'Test message. '
        });
      });
 });
</script> 
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Simpleton
  • 6,285
  • 11
  • 53
  • 87

2 Answers2

2
<script src="http://connect.facebook.net/en_US/all.js"></script>
  <script>
   $(function(){
       $("a#invite_fb_friends").click(function() {
         FB.init({
             appId:'257395654482349',
             cookie:false,
             status:true
         });
        FB.ui({
            method: 'apprequests',
            message: 'Test message. '});

        return false;
        });
   });
</script> 

is this what you are looking for?

Dennis
  • 14,210
  • 2
  • 34
  • 54
1

Just add return false; to the end of the function?

   $(function(){
       $("a#invite_fb_friends").click(function() {
           FB.init({
               appId:'257395654482349',
               cookie:false,
               status:true
           });
          FB.ui({
              method: 'apprequests',
              message: 'Test message. '
          });
          return false; //Disable default behavior.
        });
    });
Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308