Well, Select2 is a jQuery plug-in, so any other library would have to respect jQuery in order to use Select2. I guess it’s semantics, but Select2 has to fire its own version of the events because:
a. Select2 adds extra data about the selected item to the change
(and change.select2
) event,
b. Programmatically selecting an item in a <select>
does not trigger its change
native event, and
c. All the other Select2 events are non-standard, so must be generated and fired programmatically.
Given that, I suppose you could say it uses a “custom event dispatching system”, but I don’t see any other alternative. Anyway, the events it dispatches are DOMEvent
s, and (FYI), jQuery does exactly the same thing when it generates its custom events.
FYI, your “hack” is doing exactly what Select2 does, you’re just attaching the event handler in a different way (one that Select2 isn’t aware of).
I have successfully integrated Select2 with AngularJS and Angular.io, both of which have their own event systems as well. So it’s entirely possible to use Select2 with other frameworks. I’m curious what library you’re using that doesn’t seem to work with Select2’s events.
Finally, I don’t think Select2 bills itself as transparently integrating with other libraries, so you might be expecting more than it promises. In any event, if you have a solution that works for you, then that’s what’s important. Good luck with the rest of your project!