jqueryeventstreetable

How to trap the expand event in jQuery treetable


I'm using the treetable plugin in my web app. http://plugins.jquery.com/project/treeTable

I want to be able to perform an action when a specific expandable node is expanded.

I can determine which element is responsible for expanding the node. Its a span with class expander. As far as I can tell the plugin doesnt have an event that is fired when the node is expanded or toggled.

I think this is more of a jquery question than a treetable question, but how would I go about doing that.


Solution

  • Because there is no event, what you could do is replace $.fn.expand with your own function that performs the logic you need it to do, and then executes the original $.fn.expand function. E.g.

    var originalExpand = $.fn.expand;
    $.fn.expand = function(){
      // Do something
      originalExpand.apply(this, arguments);
    };
    

    That is a crude example.