Event for when a dropdown item is hovered

I have an ajax-based select2 input. Is there any event that I can use when the user hovers over a certain item in the dropdown, after the results have been returned from the server? I want the event to be caught either when the user changes the selected item with up/down arrow keys or when he uses the mouse to hover one. Is it possible?

There is no built-in event to do this. You could attach your own event handler to the dropdown that would listen for keydown and mouseover events. The problem would be mapping from the highlighted <li> in the Select2 widget (the element that fired the event) to your data, because Select2 applies identifiers to its rendered elements that have no relationship with your actual data (nor even to the “id” attribute you supply in your data object). I know of no way to perform this mapping. So you probably can’t “hack” it.

The only approach I can think of that would work is for you to override (or extend) the default ResultsAdapter to implement the custom events you desire. I would recommend studying the source code for the default ResultsAdapter and EventRelay to learn about what you would need to modify. This tutorial might also be helpful to you.