Is it bad to call .draggable function multiple times on the same element if the element has been removed between the two function calls?
I understand that attaching handlers multiple times can cause trouble, but in my case, the element in question has been removed in between the times that I'm attaching the handler. Here's a sample of what I mean:
HTML:
- <div id="parent">
- <div id="child></div>
- </div>
javascript:
- $('#child').draggable({
- helper : 'clone',
- revert : 'invalid',
- revertDuration : 400,
- opacity : 0.35,
- appendTo : 'body'
- });
- //do something in between.. then
- $('#child).remove();
- //do something else in between here...
- $('#parent').append('<div id="child"></div>');
- $('#child').draggable({
- helper : 'clone',
- revert : 'invalid',
- revertDuration : 400,
- opacity : 0.35,
- appendTo : 'body'
- });
I know there are options to make the child element invisible without removing it, but that's not really an option for me, as I am not the only one who's writing this code. I know the above code works (I've tested it), but I want to know exactly how inefficient it really is.
In other words, imagine the code between lines 12 - 24 gets executed 100 times over the course of 5 hours, without the user refreshing the webpage. Will it cause so much memory leak that it'll crash the browser, or does jQueryUI clean up the "draggable state" well enough under the hood that I don't need to worry about memory leaks?