First let me say this has caused me hours of agony, and I've tried my best to find resources and grasp why this is happening.
- I have a file browser that works off AJAX.
- When I load a new directory, I have to re-initialize event handlers
- When I change directories, it stacks.
So if I go to say files/../files/..
to get back to the root (twice), it fires 4 times.
I have tried unbinding with .off()
, I've tried restricting with .one()
, I've tried resetting ALL binds with $(document).find('*').off()
and with specific events, I have tried e.stopPropagation();
.
Nothing seems to work. This is driving me nuts. If I don't re-initialize the system, the new content loaded via AJAX does not receive the binds. If I do, it stacks. Please help!
//previous method
file.on('click',dothis);
//method that actually works
files.on('click','a',dothis);