我有一份带有图表的工作文件。我已向图表中添加了多个单元格,并且正在尝试监听 cell:highlight
事件,但我从未收到它。
我正在做:
paper.on('cell:highlight', function() { ... });
其他事件似乎工作正常,例如:blank:pointerup
,...
是否需要采取一些特殊措施才能使细胞事件发挥作用?
最佳答案
根据文档:
cell:highlight
- triggered whenhighlight()
method is called on either an element or a link. Note that this method is also called automatically when the user is reconnecting a link and the connection is valid (validateConnection()
returns true) or ifembeddingMode
is enabled on the paper and the dragging element is above another element it could be dropped into (validateEmbedding()
returns true). The handler for this event has the following signature:function(cellView,el)
. The handler defaults tofunction(cellView, el) { V(el).addClass('highlighted') }
. In other words, the 'higlighted' CSS class is added and so you can style the highlighted element in CSS. If you want to use a different method for highlighting cells, callpaper.off('cell:highlight')
first to unregister the default handler and thenpaper.on('cell:highlight', myHandler)
to register your own.
您可以阅读更多相关信息here .
关于jointjs - 不触发单元格事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34904621/