title: Wordpress - insert Ajax-based login form upon link click event
body: <p>I'm looking to get help with a WordPress staging site located at:</p>
  
  <p><a href="http://sbane39-beta.knowarecms.net" rel="nofollow">http://sbane39-beta.knowarecms.net</a>. </p>
  
  <p>I'm trying to get an existing Ajax-based login form to display when a non-logged-in user clicks an 'Add To Cart' button in my installation of the Event Espresso event management plugin. </p>
  
  <p>An Ajax-based login form already exists, and functions properly when a user clicks the "Member Log In" button located just below the scrolling slideshow in the header of the page.</p>
  
  <p>However, a copy of the form that is should be called when an "Add To Cart" button (in the main nav bar, click Events, All Events to see a list of available events) is clicked doesn't appear - instead, the default behavior of the link fires, which is a redirection to the Event Espresso shopping cart with the specific event added to it.</p>
  
  <p>In both cases, the click event is being handled by the script at :</p>
  
  <p><a href="http://sbane39-beta.knowarecms.net/wp-content/themes/sbanenew/js/ajax-login-script.js" rel="nofollow">http://sbane39-beta.knowarecms.net/wp-content/themes/sbanenew/js/ajax-login-script.js</a>. </p>
  
  <p>In the case of the "Member Log In" button, the handler function is:</p>
  
  <pre><code>$("a[title='memberlogin']").on('click', function(e){...} 
  </code></pre>
  
  <p>For the "Add to Cart" buttons, the handler function is:</p>
  
  <pre><code>$("a[id^='cart_link_']").on('click', function(e){...}
  </code></pre>
  
  <p>When debugging the later, I can see that the function is being called on the click event, but for some reason preventDefault action isn't working to stop execution. </p>
  
  <p>I added the return false statement to stop propagation, but with no luck.</p>
  
  <p>My JS debugging skills aren't good enough to see why this is happening. Hopefully this forum is the appropriate place to seek help, so TIA for any guidance.</p>
  
  <p>In response to brybott's request, here's the (modified) code with the return false statement moved:</p>
  
  <pre><code>$("a[id^='cart_link_']").on('click', function(e){ //When an Add To Cart button is clicked...        
      e.preventDefault();//prevent the default action
      //$addToCartURL = $(this).attr('href');
      //display event login form only to logged out users
      jQuery.post(ajax_login_object.ajaxurl, data, function(response) {
          if(response == 'yes') {
              //alert('You are already logged in');
          } else {
              $formLoginEvent.fadeIn(1000);//Fade the form in
              $('form#login_event a.close').on('click', function(e){
                  e.preventDefault();
                  $('form#login_event').fadeOut(1000);
              });
              return false; //stop propagation
          }
      }); 
  });
  </code></pre>