Enhacement suggestion
Closed this issue · 4 comments
Great library.
One problem i had was the need to have a unique id for each of the checkbox.
It's easy to do with particular pages, but with a large system can be complicated (when you have custom controls and some other things).
So, trying to not use the id to link the label and the input, i have this solution:
<label>
<input type="checkbox" value="0">
<span class="label"></span>
</label>
I put a label over all elements (get ridding of the needed id) and an span with .label class to maintain the use of the CSS's. Changing them to:
:checked + .label:after {
Using ".label", not "label"
What do you think about the change?
Hello Martin,
The recommended way by W3C to use a checkbox and a label is with the for
and id
attribute. I will look into this in more detail and will wait for input by other people.
I did some R&D and i think i will stick to the current markup. I think in your case you can create the ids dynamically so that you are using label and checkboxes the better way :) .
Ok, i understand.
I will stand with my alternative because in a large system, using angular for example, you need to force the developers to remember setting an id, and if they forgot, it's difficult to find those type of errors.
I think in angular the modal can be used for the id.