jQuery plugin removes event and data bindings.

Archived from the Transloadit support forum. Originally posted on November 25, 2010; details may be outdated, see our docs for current behavior. Original thread

My use case:

Form with single input[type=file] box. I bind a click event to the input. When user chooses a file I trigger the upload with a .submit() call, transloadit settings autoSubmit: false, wait: true. I get back my results, and add hidden meta info to the input box via jQuery’s .data().

After the .submit(), the click event handler has been removed from the input, as well as any .data(). It is as if the old input DOM element is either completely replaced or all data associated with it has been erased.

My current work around is (1) rebind my event handler in transloadit’s onSuccess, and (2) don’t use .data() on the file input.

I will look into this, should not be too hard to fix!

Ping. This issue still exists.

Dennis was so kind to help himself fix this issue and provide a pull request:

https://github.com/English360/transloadit-jquery-sdk/commit/REDACTED

Basically the cloned file input fields also copy over their events and data now, see http://api.jquery.com/clone/ .

To me this seems like the right fix. I set up a test environment and couldn’t find a problem related to it. I also don’t see in the jQuery plugin how other side effects could occur from this.

Felix please check it out and merge it if you see fit.

Thanks Dennis for the patch and a big sorry that this ticket hasn’t been worked on for so long.

Kind regards,
Tim

Merged this a while ago.