views:

487

answers:

3

Hi,

I am using a highly modified version of the jqueryFileTree plugin, that is able to add new files and folders. When a new file is created in realtime I have to bind the tree again to the click event so that all new files and folders can work as intended.

Just re-binding the filetree has caused me some trouble with the functionality of folders. For every new file the filetree runs bind which means that when you add one file and then click on a directory to close it, it opens and then closes because the function is run two times.

I localized the problem recently and am trying to unbind all events connected to the filetree before rebinding. However, the problem still occurs. Why could this be? Syntax error?

$('UL.jqueryFileTree').unbind();
bindTree('UL.jqueryFileTree');

Cheers!

Chris

A: 

But if Unbind causes a problem you can use RemoveAttr() to remove events from elements. Because there is a bug at unbind event in jQuery.

Braveyard
+1  A: 

Aha!

I should have done my research better. It works fine after writing this instead:

$('UL.jqueryFileTree').find('LI A').unbind();
bindTree('UL.jqueryFileTree');
Christoffer
It's great to hear that's working.
Braveyard
A: 

Also look in to jQuerys live-event. Perhaphs you don't need to rebind. Might work better.

ie

$('#divId a').live('click', function(e){
   //do something to all matched and future elements
});