Following the example here I have tried to override the show() mehtod of a Primefaces context menu.
Here my code:
<p:tree value="#{myTreeBean.mainTreeRoot}" id="myTree>
<p:ajax event="contextMenu" listener="#{myTreeBean.onRightClickSelectListener}" oncomplete="PF('serverTreeMenuVar').show()"/>
[...]
</p:tree>
<p:contextMenu widgetVar="myTreeMenuVar" for="myTree" id="myTreeMenu" model="#{myBean.contextMenuModel}"></p:contextMenu>
<script>
$( function() {
PF('myTreeMenuVar').show = function(e) {
console.log('my function');
// call the generic implementation:
PrimeFaces.widget.ContextMenu.prototype.show.call(this,e);
}
});
</script>
Unfortunately I get the error:
Uncaught TypeError: Cannot read property 'pageX' of undefined
I'm using PF 7.0