alexukf

3464377

Jan 23rd, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 1.45 KB | None | 0 0
  1. diff -git a/js/sql.js b/js/sql.js
  2. index a07d7e7..25f4dd0 100644
  3. --- a/js/sql.js
  4. +++ b/js/sql.js
  5. @@ -136,6 +136,31 @@ $(document).ready(function() {
  6.          $form.find("select[name=id_bookmark]").attr("value","");
  7.          // let normal event propagation happen
  8.      });
  9. +  
  10. +    /**
  11. +     * Event handler for hitting enter on sqlqueryform bookmark_variable
  12. +     * (the Variable textfield in Bookmarked SQL query section)
  13. +     *
  14. +     * @memberOf    jQuery
  15. +     */
  16. +    $("input[name=bookmark_variable]").bind("keypress", function(event) {
  17. +        // force the 'Enter Key' to implicitly click the #button_submit_bookmark
  18. +        var keycode = (event.keyCode ? event.keyCode : (event.which ? event.which : event.charCode));
  19. +        if (keycode == 13) { // keycode for enter key
  20. +            // When you press enter in the sqlqueryform, which
  21. +            // has 2 submit buttons, the default is to run the
  22. +            // #button_submit_query, because of the tabindex
  23. +            // attribute.
  24. +            // This submits #button_submit_bookmark instead,
  25. +            // because when you are in the Bookmarked SQL query
  26. +            // section and hit enter, you expect it to do the
  27. +            // same action as the Go button in that section.
  28. +            $("#button_submit_bookmark").click();
  29. +           return false;
  30. +        } else  {
  31. +           return true;
  32. +        }
  33. +    });
  34.  
  35.      /**
  36.       * Ajax Event handler for 'SQL Query Submit'
Advertisement
Add Comment
Please, Sign In to add comment