diff --git a/js/commerce_stripe.form.js b/js/commerce_stripe.form.js
index c6ebb17..0ced8ee 100755
--- a/js/commerce_stripe.form.js
+++ b/js/commerce_stripe.form.js
@@ -139,15 +139,23 @@
       });
     },
 
-    detach: function (context) {
+    detach: function (context, settings, trigger) {
+      // Detaching only when it is needed.
+      if (trigger !== 'unload') {
+        return;
+      }
       var self = this;
       ['cardNumber', 'cardExpiry', 'cardCvc'].forEach(function (i) {
-        if (self[i]) {
+        if (self[i] && self[i].length > 0) {
           self[i].unmount();
           self[i] = null;
         }
       });
-      $('.stripe-form', context).closest('form').off('submit.commerce_stripe');
+      var $form = $('.stripe-form', context).closest('form');
+      if ($form.length === 0) {
+        return;
+      }
+      $form.off('submit.commerce_stripe');
     }
   };
 
