Key up event not working on dhxList


#1

Key up event not working on dhxList.

I want to get the keyup from the event in dhxList, but the eventHandlers are not working with the keyup. Also, the component does not contain the event keyup.

How can I do this ?

Example of this:
https://snippet.dhtmlx.com/l7yaamym


#2

I am not familiar with a keyup event for a List control? Is there a possibility that you could use a window property event-listener? If so, don’t try and use the normal “id” attribute because that doesn’t work. You should use the “data-dhx-id” attribute. Something like:

document.querySelector(’[data-dhx-id=“list_id_assigned”]’)


#3

Yes, this works. I register the event listener in the component list by sel, then I get the item selected by the selector “.dhx_list-item.dhx_list-item–selected”. This way:

document.querySelector(".dhx_widget.dhx_list").addEventListener('keyup', function (ev) {
     const idSelected = $('.dhx_list-item.dhx_list-item--selected').attr('data-dhx-id'); // here i am using jquery
     setSelectedItem(list.selection.getId());
});

But in my opinion this seems to be an implementation fault or bug. The list already provides its events, also a way of attaching via the list.events.on() method, and the eventHandlers property to add events to the template in the list, so why only the event keys don’t work?

It wasn’t hard to solve the situation, but I think the api should provide a way to do this.

Anyway, thanks for the guidance, it helped me to solve it.


#4

Unfortunately currently there is no registered keyUp event in the dhx.List API.
The only solution is to use the native JS event suggested by the @ND_Results