"onItemClick" event returns previously selected list item instead of current one

Hi everyone! I’m new to webix (and JS) and I have a question about attaching an onItemClick event to a List:

myList.attachEvent(“onItemClick”, function(id) {
console.log(this.getSelectedItem(false).id);
}

In this situation, the console outputs the previously selected list item instead of the current one (with undefined being output the first time). If you have any ideas, please let me know.

Thanks!

If you need the id of clicked item, you can take if from id parameter of event.

If you need to track selection, just use onAfterSelect event instead ( on moment of onItemClick selection is not moved to the new item yet )

http://webix.com/snippet/c3e2fe6f

onAfterSelect worked perfectly. Thanks!