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.
Comment | File | Size | Author |
---|---|---|---|
#7 | jquery_update-2247523-7.patch | 1.43 KB | aviindub |
#6 | jquery_update-2247523-6.patch | 898 bytes | aviindub |
#4 | jquery_update-2247523-4.patch | 516 bytes | bc |
#1 | jquery_update-2247523-1.patch | 722 bytes | mesch |
Comments
Comment #1
mesch CreditAttribution: mesch commentedProposed patch using the delegate() method attached and tested locally as per above.
Comment #2
jasonkryst CreditAttribution: jasonkryst commentedI 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.
Comment #3
jasonkryst CreditAttribution: jasonkryst commentedDisregard the above comment. I have implemented the above patch and am able to confirm that it functions as necessary
Comment #4
bc CreditAttribution: bc commentedUpdated patch for latest commerce_stripe js changes.
Comment #5
aviindub CreditAttribution: aviindub commentedre #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.
Comment #6
aviindub CreditAttribution: aviindub commentedheres 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.
Comment #7
aviindub CreditAttribution: aviindub commentedupdated 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.
Comment #8
aviindub CreditAttribution: aviindub commentedComment #11
apaderno