What is the best practice for working with HTML IDs in Nette 2.3

Notice: This thread is very old.
Member | 64


in Nette 2.3 Buttons and Hidden fields are generated without HTML ID. What is the reason and what is the best practice for ID handling in JS for hidden fields and for text inputs (for example)? Because specifying ID manually for every input in large project is very tough.

David Grudl
Nette Core | 7444

Relying on the automatically generated ID was always a bad practice, as these may be changed. Due to a change in the framework, or after you rename item (and do not realize that it is bound to ID in JavaScript).

Good practice is to set up your own ID using setHtmlId() or set class or other HTML attribute using setAttribute().