Commit 2653f0ad by Clinton Blackburn

Fixed credit form submission bug

Firefox requires the form to be attached to a DOM element

ECOM-2492
parent 7427d82c
...@@ -23,6 +23,7 @@ var edx = edx || {}; ...@@ -23,6 +23,7 @@ var edx = edx || {};
context: this, context: this,
success: function (requestData) { success: function (requestData) {
var $form = $('<form>', { var $form = $('<form>', {
'class': 'hidden',
'action': requestData.url, 'action': requestData.url,
'method': 'POST', 'method': 'POST',
'accept-method': 'UTF-8' 'accept-method': 'UTF-8'
...@@ -35,7 +36,7 @@ var edx = edx || {}; ...@@ -35,7 +36,7 @@ var edx = edx || {};
}).appendTo($form); }).appendTo($form);
}); });
$form.submit(); $form.appendTo('body').submit();
} }
}); });
}; };
......
...@@ -288,6 +288,8 @@ function completeOrder(event) { // jshint ignore:line ...@@ -288,6 +288,8 @@ function completeOrder(event) { // jshint ignore:line
providerId = $(event).data("provider"), providerId = $(event).data("provider"),
$errorContainer = $("#error-container"); $errorContainer = $("#error-container");
event.preventDefault();
analytics.track( analytics.track(
"edx.bi.credit.clicked_complete_credit", "edx.bi.credit.clicked_complete_credit",
{ {
......
...@@ -36,6 +36,8 @@ var edx = edx || {}; ...@@ -36,6 +36,8 @@ var edx = edx || {};
username = $target.data("user"), username = $target.data("user"),
providerId = $target.data("provider"); providerId = $target.data("provider");
event.preventDefault();
edx.commerce.credit.createCreditRequest(providerId, courseKey, username).fail(function () { edx.commerce.credit.createCreditRequest(providerId, courseKey, username).fail(function () {
$(".credit-action").hide(); $(".credit-action").hide();
$errorContainer.toggleClass("is-hidden"); $errorContainer.toggleClass("is-hidden");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment