Skip to content

Commit

Permalink
fix modal auto-submitting
Browse files Browse the repository at this point in the history
  • Loading branch information
Berkeley Martinez authored and Berkeley Martinez committed Sep 10, 2015
1 parent 0791c99 commit 2186f36
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions client/commonFramework.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ var testSuccess = function() {
function ctrlEnterClickHandler(e) {
// ctrl + enter
if (e.ctrlKey && e.keyCode === 13) {
$('#complete-courseware-dialog').off('keydown', ctrlEnterClickHandler);
$('#submit-challenge').click();
}
}
Expand All @@ -441,17 +442,9 @@ function showCompletion() {
var bonfireSolution = myCodeMirror.getValue();
var didCompleteWith = $('#completed-with').val() || null;


$('#complete-courseware-dialog').modal('show');
$('#complete-courseware-dialog .modal-header').click();

$('#complete-courseware-dialog').keyup(function(e) {
// ctrl + enter
if (e.ctrlKey && e.keyCode === 13) {
$('#submit-challenge').click();
}
});

$('#submit-challenge').click(function(e) {
e.preventDefault();

Expand Down Expand Up @@ -785,12 +778,12 @@ $(document).ready(function() {

// init modal keybindings on open
$('#complete-courseware-dialog').on('shown.bs.modal', function() {
$('#complete-courseware-dialog').keyup(ctrlEnterClickHandler);
$('#complete-courseware-dialog').keydown(ctrlEnterClickHandler);
});

// remove modal keybinds on close
$('#complete-courseware-dialog').on('hidden.bs.modal', function() {
$('#complete-courseware-dialog').unbind('keyup', ctrlEnterClickHandler);
$('#complete-courseware-dialog').off('keydown', ctrlEnterClickHandler);
});

var $preview = $('#preview');
Expand Down

0 comments on commit 2186f36

Please sign in to comment.