Jquery Treeview Won't Work After Refreshing/reloading A Branch


I am using this as a base to have a treeview, which gets populated by AJAX: http://www.yiiframework.com/wiki/70/display-an-ajax-tree-from-your-db-using-ctreeview

I am using it to structure citys and places, e.g.:

It works great, but I needed to have the possibility to add a place on the fly.

So I found this mod: http://forum.jquery.com/topic/jquery-treeview-async-treeview-reload-branche - which was still working! (You need the modified js? Get jquery.treeview.js (mod begins at 107) and jquery.treeview.async.js (mod begins at 108))

So, in my views/place/index.php I had a javascript dialog, where you could create a new place. When created, it called:


placeId is the place of the parent place, e.g when adding “Augsburg” to “Bayern”, it would have Bayern’s id. Bayern now reloaded - which was great. But the +/- sign for expanding/collapsing stopped working at the whole level. Another branch, which is at equal level like “Deutschland” was still working.

So I tried something else, more radical:



This clears everything out of the ul and does the same thing which is done on $(document).ready() to populate the treeview the first time.

However, this has the same problem. +/- does not work.

Searching through the internet, some people discovered this problem, but I could find no solution.

Does anybody have a solution? I’d also switch to dynatree or jqTree, but I have found people which also have the same problem (adding something and reloading a branch) with these extensions, so I’d better stick with treeview.

Any jQuery-Guru here? At this time, I cannot publicly give you the site where this all happens, as it is in closed beta, but if someone is really interested, I could pm the credentials.

Edit: I already found this “solution” which seems to me more of a hack and doesn’t reload a single branch, but the whole tree (this would be ok, but it isn’t THE solution): https://groups.google.com/d/msg/jquery-en/yFjE8K47UPU/-WnQdNGkUQsJ