Custom node event handlers lost when filter extension used

77 views Asked by At

This is a bit of an edge case, but I have custom event handlers attached to elements embedded in the fancytree node title element. I bind these handlers to child elements in the title span during the createNode() callback using jQuery selectors and on(). This approach accounts for new elements being added when the folder nodes are expanded. However, when I also use the filter extension, these event binding are lost - even when I reset the filter to show the full tree again. The createNode callback is not called again after the filter reset, so I'm wondering if there is some other callback I should use to bind events once such that the are not unbound by the filter. Thanks!

1

There are 1 answers

0
Dale On

I've identified the issue. The Fancytree filter replaces the html/text content of the node title span (whether hidden or not) which results in local event handlers being lost. A partial fix for this is to attach delegate event handlers on the parent fancytree-container div. This works while the filter is not active; however, when a filter is applied, the html content of highlighted nodes is replaced with new content generated by the filter extension, thus any custom embedded/active html elements are missing on these nodes. I don't see an easy fix for this problem short of writing an application-specific tree filter.