Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File input events #28

Open
valtronforever opened this issue Aug 13, 2013 · 2 comments
Open

File input events #28

valtronforever opened this issue Aug 13, 2013 · 2 comments

Comments

@valtronforever
Copy link

When I try to bind change event to file input:

$file = $('<input type="file" name="file" multiple>')
     .appendTo('form').change(function(){
           that.onFileChange();
     });

This works for first upload, but next fail. As I understood, the elements are replaced. Please add replacing events to.

@matthewtuck
Copy link

I have had this issue trying to use this code too, it seems to be due to this code:

  // Move the file fields into the hidden form, but first remember their
  // original locations in the document by replacing them with disabled
  // clones. This should also avoid introducing unwanted changes to the
  // page layout during submission.
  markers = files.after(function(idx) {
    return $(this).clone().prop("disabled", true);
  }).next();
  files.appendTo(form);

As a result, your code is moved into IFRAME and won't run the second time.

The easiest solution for the author of this product would seem to be putting the clones in the IFRAME instead, or perhaps using something like clone(true) to also clone events.

The easiest workaround for the users of this product I found was to use live type events, i.e. the selector parameter of the 'on' function.

@chrishoage
Copy link

This is actually due to the commit in this pull request: #24 (comment)

I have asked the author to revert the commit.

The issue is that he is not putting back the original file inputs after replacing them with markers.

If you look at the code for the linked pull request you can see the offending code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants