Closed luksan47 closed 2 years ago
The js initializer will be applied to all the select elements with the given id. I'm just thinking if we could handle this feature automatically, without explicitly setting the once flag. Maybe we can check if the page has already a script for this id or sth like that. @luksan47 , what do you think?
We cannot really do that as this optimization can only be applied when the element lists are the same.
However, now that I think about it, I'm not even sure that my solution is working. For some reasons I thought that the select is initializing all selects, and not only the one with the id. If we are initializing only one ID, we cannot use the once directive. We would have to rewrite the JS code as well, replacing #<id>
with .select
.
This might cause slowness on pages with multiple selects, like on the mr and miss page. Instead of including the scripts multiple times, which has a lot of content (the whole user list), we could load it only once.
This commit adds a
once
attribute to the select component, which would let us load the select init script once per page. Note that this can be used only if we have exactly once type of select on the page, as the other would break, since they won't have the same user list in their init script.Fixes #580.