# HG changeset patch # User Nathan Phillip Brink # Date 2011-03-21 00:50:08 # Node ID 4f8efb27e2ab14030f2f7a85acb62b35767226a8 # Parent 71e300c8c55b4f094317a5548418a8fbb2684b88 Turn in a course_id textfield input into a noop to prevent accidental form submission during autocomplete. diff --git a/scripts/scheduleInput.js b/scripts/scheduleInput.js --- a/scripts/scheduleInput.js +++ b/scripts/scheduleInput.js @@ -252,6 +252,28 @@ function add_sections(cnum, data) jQuery('#tr-course-' + classNum).data({course_i: classNum}); var class_elem = jQuery('.className' + classNum); + + + /* + * Don't let the user accidentally submit the form by + * pressing . Instead, select the first + * autocomplete result if possible. + */ + class_elem.bind('keyup keydown', function(e) + { + /* is 13 */ + if (e.which == 13) + { + /* + * The user has pressed enter before selecting an autocomplete entry, which means the + * form will be submitted without his expecting it to be. We yet need code + * to figure out what the first autocomplete result is :-/. + */ + return false; + } + return true; + }); + class_elem.autocomplete({ source: 'auto.php' }); class_elem.bind('autocompleteselect', {class_num: classNum, class_elem: class_elem}, function(event, ui)