cellView.findBySelector([selector, root, selectors])
Return an array of subelements of this CellView which are identified by selector
. If no such subelements are found, return an empty array.
This method mimics jQuery element search methods in that it always returns an array. If you are only expecting to find a single subelement (most common scenario), you can get it by accessing the first element in the returned array – e.g. this.findBySelector('body')[0]
.
If you do not specify a selector
, the root
of the CellView is returned as the only element of the return array. For backwards compatibility, the same applies also if you provide the special value selector = '.'
. By default root = this.el
(the wrapping <g>
SVGElement of the CellView), but if you provide a different root
(see below), then that value is returned instead.
By default, JointJS searches for matching subelements among descendants of this.el
SVGElement. As an advanced feature, you may provide a different root
– e.g. an el
SVGElement of another CellView. Then JointJS searches for matching subelements among the descendants of that SVGElement.
By default, JointJS uses this.selectors
array for reference. (The selectors
array is a cached structure of this CellView's SVGElement descendants as defined by the markup
attribute of the Cell model from which the CellView was initialized.) As an advanced feature, you may provide a different selectors
array for the search – e.g. a selectors
array of another CellView.
(Deprecated) For backwards compatibility, if no matching subelement is found among selectors
, then jQuery is used to try and find an element through CSS selectors ($(root).find(selector).toArray()
). If you are using standard shapes, you may disable this functionality for increased performance by setting useCSSSelectors = false
in the global config.