Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

So the first thing we will do is add jQuery to our screen branding.  This code is pretty generic and should work in versions of jQuery from 1.4.X up to the latest.

Code Block
themeDJango
languagehtml/xml
titleInclude jQuery from Google's Server
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>

Now we need to attach a key press handler to the coupon code entry field and then give it logic to click the apply coupon submit button.

Code Block
themeDJango
languagehtml/xmljavascript
titleKey Press Handler
<script type="text/javascript">
jQuery(document).ready(function() {
  jQuery('input[name="couponCode"]').keypress(function (e) {
      var code = e.keyCode || e.which;
      if (code === 13) {
        e.preventDefault();
        jQuery("#APPLY_COUPON").click();
      }
   });
});
</script>

...