Focus to first field after insert?
- Single Page
Posted 28 April 2012 - 11:49 AM
However, I noticed that the focus stays on the field where you pressed the enter button. Wouldn't it be more convenient/logical to set the focus to the first edit field of the now empty form after adding the new record? In that way, you don't need to reach for the mouse to set the focus to the first field to start entering another record.
(Of course, this should not happen in editing mode, only after adding a record. In editing mode the form fields currently keep their content, which is good, and keeping the focus on the last edited field is what you'd expect, IMHO.)
Posted 28 April 2012 - 14:23 PM
Posted 04 May 2012 - 21:17 PM
In assets/grocery_crud/themes/flexigrid/js/flexigrid-add.js there on line 42, you'll find this statement:
clearForm();
This is where the form gets cleared after a successful insert. I added this line (line number 45), which does the trick:
$("form input:visible:first").focus();
It selects the first visible input of the form and sets the focus to that field.
Posted 09 June 2013 - 19:33 PM
What about datatables theme? How I can set focus on the first element on an add/edit operation? Thank you very much!!