Problem:

Enabling jQuery Update Module with jQuery version 1.9 or higher breaks the checkout form javascript added by this module. Closer inspection identifies the culprit as the live() method which is deprecated as of jQuery 1.7 and removed in jQuery 1.9. As a result, the code fails to attach the Stripe event handler to the submit button click event, and the Stripe token isn't fetched.

Affects:

Anyone using jQuery 1.9 or higher would be affected.

Solution:

The delegate() method performs a similar function to live() and is supported by Drupal core jQuery (v. 1.4.4.) and subsequent versions. I will attach a patch below.

The recommended approach of using the on() method is not compatible with core Drupal jQuery, so we would be solving one problem while creating another one. I also looked into bind() but it turns out that's more trouble than its worth because of commerce_checkout.js which, to prevent double-clicking the submit button, clones the button when it's clicked. Binding this module's event handler to that new button is problematic.

Testing:

I tested this using core Drupal (jQuery v.1.4.4) and jQuery v.1.10 (by way of jQuery Update module). Tested on both checkout and checkout review pages.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mesch’s picture

FileSize
722 bytes

Proposed patch using the delegate() method attached and tested locally as per above.

jasonkryst’s picture

Status: Needs review » Needs work

I have integrated this patch and am unable to run payments. The address fields are submitted as undefined/null within the token. I am currently looking into this issue. Let me know if you come across any updates.

jasonkryst’s picture

Status: Needs work » Reviewed & tested by the community

Disregard the above comment. I have implemented the above patch and am able to confirm that it functions as necessary

bc’s picture

FileSize
516 bytes

Updated patch for latest commerce_stripe js changes.

aviindub’s picture

re #4: i want to move away from using the generic #edit-continue selector. also, we don't want to use .on() because it is not supported in the version of JQuery that ships with drupal core.

I am going with the line from the original patch, except i have to redo the patch because it wont't apply against the latest changes.

aviindub’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
898 bytes

heres what i think i am going with. i couldnt devise a good way to get away from the #edit-continue selector, but this patch at least addresses the use of deprecated JQuery functions without breaking compatibility with base drupal core.

aviindub’s picture

updated version of patch from #6.

this applies against a3ced3661793bfe7097d92b85c4261538f0a52f3, and not any current tag or branch. I will include it in a larger patch for rc7.

aviindub’s picture

Status: Needs review » Fixed

  • aviindub committed 3d670d2 on 7.x-1.x
    Issue #2247523 by aviindub: removes uses of the deprecated live()...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

apaderno’s picture

Issue tags: -jquery javascript +jQuery