I have a progressively enhanced <select>
element in HTML.
It uses the following form,
<ul>
<li></li>
<li></li>
...
</ul>
With the current implementation, the click
event handler is attached to every li
element.
Will this create a problem when you have, say, about 1000-2000 elements, will it be slower as compared to attaching a single event handler to the <ul>
and picking necessary information from e.srcElement
?
Current implementation:
There is the whole list of
<div>
<select>
//1000-2000 elements
<option> </option>
</select>
<ul>
//Mapping the values of the 1000-2000 option tags
<li> </li>
</ul>
</div>
The click
event handler maps the selected li
to its equivalent option
, sets that as the selected
item and triggers the change event for the select
.
` makes sense here, but without seeing what the event handler is doing, it's hard to for sure say that it is the best route. I can't imagine that it would be better to attach it to each `- ` though, since you already have a reference to the clicked `
- ` in the event object.
– crush Dec 18 '13 at 13:37