I am adding a context menu to a tree and trying to resolve some issues.
In various examples I see a “$(‘#jqxTree li’).on(‘mousedown’…” event followed by an ‘isRightClick(event)’ function being used to invoke a context menu. I wonder why you do not just use “$(‘#jqxTree li’).on(‘contextmenu’…” which seems to work for me (I have disabled the default browser context menu).
I also see the context menu handler being re-attached to the tree whenever a tree item is added or removed. I have also found this necessary but I am not clear why. This also causes me a problem if I refresh the tree as I then find the context menu handler being called multiple on a single click.
If the $('#jqxTree li').on('contextmenu'... solution works fine on your side, you are free to use it.
The context menu handler is reattached, because when an item is added or removed, the widget is refreshed and all elements inside are recreated, thus in need of event handlers. Perhaps this information will help you figure out your refresh-related issue.