Nette 2.3 Buttons and Hidden fields
- littleblackdog11
- Member | 1
Hi,
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.
- dakur
- Member | 438
@littleblackdog11 I guess there is no reason to generate them because the framework does not need them. If you do, just add them.
But it seems to me that you misunderstood the semantics of ID. It is meant
for targeting specific elements (e.g. dark mode switch button, menu icon etc.)
not lists of elements (“do something on all table cells”, “add event
listener on all remove buttons”). If you need to do so, you should rather use
tag or class name selector like this:
document.querySelectorAll('table td')
/ document.querySelectorAll('.someClassName')
If it is not what you meant, elaborate please a bit what are you exactly trying to achieve.
Last edited by dakur (2020-10-26 09:16)