Changeset - 4f8efb27e2ab
[Not reviewed]
default
0 1 0
Nathan Brink (binki) - 15 years ago 2011-03-21 00:50:08
ohnobinki@ohnopublishing.net
Turn <enter> in a course_id textfield input into a noop to prevent accidental form submission during autocomplete.
1 file changed with 22 insertions and 0 deletions:
0 comments (0 inline, 0 general)
scripts/scheduleInput.js
Show inline comments
 
@@ -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 <ENTER>. Instead, select the first
 
		 * autocomplete result if possible.
 
		 */
 
		class_elem.bind('keyup keydown', function(e)
 
				  {
 
				      /* <ENTER> 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)
0 comments (0 inline, 0 general)