CTreeView using url and toggle


I’m using CTreeView with ‘url’ and ‘toggle’ and both seem to work but I have a bit of a problem. It appears the ‘toggle’ callback happens right when a node is clicked which is before the AJAX request can finish loading the new node. So how can one tell via Javascript when a dynamic CTreeView node has finished loading?



Guess I should know these things but with some digging I found a solution to my problem. When using CTreeView with ‘url’ for AJAX loading ‘toggle’ only fires when a node is clicked. I was able to determine when nodes are done loading using jQuery by register a global .ajaxComplete() listener and then using the AJAX url to determine the request. The javascript looks something like this:





function ajaxJustFinsihed(event, XMLHttpRequest, ajaxOptions)


    if(ajaxOptions.url.indexOf('ajaxFillTree')) {

        alert('Finished loading AJAX tree nodes');



If there is a better way I would like to know. Otherwise I hope this information save someone some time.