Fix issue with duplicate submits
This commit is contained in:
@ -6,25 +6,10 @@ window.common = (function(global) {
|
||||
common = { init: [] }
|
||||
} = global;
|
||||
|
||||
common.showCompletion = function showCompletion() {
|
||||
|
||||
ga(
|
||||
'send',
|
||||
'event',
|
||||
'Challenge',
|
||||
'solved',
|
||||
common.gaName,
|
||||
true
|
||||
);
|
||||
function submitChallengeHandler(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var solution = common.editor.getValue();
|
||||
var didCompleteWith = $('#completed-with').val() || null;
|
||||
|
||||
$('#complete-courseware-dialog').modal('show');
|
||||
$('#complete-courseware-dialog .modal-header').click();
|
||||
|
||||
$('#submit-challenge').click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$('#submit-challenge')
|
||||
.attr('disabled', 'true')
|
||||
@ -60,7 +45,6 @@ window.common = (function(global) {
|
||||
const data = JSON.stringify({
|
||||
id: common.challengeId,
|
||||
name: common.challengeName,
|
||||
completedWith: didCompleteWith,
|
||||
challengeType: +common.challengeType,
|
||||
solution,
|
||||
timezone
|
||||
@ -82,7 +66,24 @@ window.common = (function(global) {
|
||||
.fail(function() {
|
||||
window.location.replace(window.location.href);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
common.showCompletion = function showCompletion() {
|
||||
|
||||
ga(
|
||||
'send',
|
||||
'event',
|
||||
'Challenge',
|
||||
'solved',
|
||||
common.gaName,
|
||||
true
|
||||
);
|
||||
|
||||
$('#complete-courseware-dialog').modal('show');
|
||||
$('#complete-courseware-dialog .modal-header').click();
|
||||
|
||||
$('#submit-challenge').off('click');
|
||||
$('#submit-challenge').on('click', submitChallengeHandler);
|
||||
};
|
||||
|
||||
return common;
|
||||
|
Reference in New Issue
Block a user