⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

focus first field on add action... (datatables theme)



Charles A.
  • profile picture
  • Member

Posted 23 June 2013 - 03:08 AM

Hi,

how can I set focus on the first element of the form when adding a new record? (in datatables theme).

Thanks!

 

 


davidoster
  • profile picture
  • Member

Posted 23 June 2013 - 05:01 AM

For this you will need to use jQuery and go under assets/grocery_crud/themes/datatables/js open datatables.js and there add the proper jquery code.

Somewhere under line 16 on the $(document).ready(function() {

and type... https://www.google.gr/search?q=jquery+focus+on+first+input+&rlz=1C1AVSI_enGR470GR470&oq=jquery+focus+on+first+input+&aqs=chrome.0.57j0l3j62l2.14000j0&sourceid=chrome&ie=UTF-8


Charles A.
  • profile picture
  • Member

Posted 23 June 2013 - 19:26 PM

Thanks for your answer! What I really did was to edit under 
 assets/grocery_crud/themes/datatables/js

 

the files

datatables-edit.js

datatables-add.js

 

and add this line somewhere after "$(function(){".... 

$("#crudForm input:text").first().focus();

Works perfect ;)