diff --git a/app/static/js/create_item.js b/app/static/js/create_item.js index 76e3dede94d4a9c26438fa55dc96af37773182de..008bbcd28c9b0d32ba8658b3252a259c35b361fd 100644 --- a/app/static/js/create_item.js +++ b/app/static/js/create_item.js @@ -1,5 +1,12 @@ $(document).ready(function() { + $.fn.focusWithoutScrolling = function(){ + var x = window.scrollX, y = window.scrollY; + this.focus(); + window.scrollTo(x, y); + return this; //chainability + }; + // Focus to ICS id when loading the page $("#ics_id").focus(); @@ -19,10 +26,9 @@ $(document).ready(function() { // Focus on the submit button so that scanning the Submit action // will submit the form (due to the CR sent by the scanner) $("#serial_number").keydown(function(event) { - console.log(event.keyCode); if(event.keyCode == 13) { event.preventDefault(); - $("#submit").focus(); + $("#submit").focusWithoutScrolling(); return false; } });