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

Fileinput does not work with refile gem #359

Open
jemminger opened this issue Apr 1, 2015 · 4 comments
Open

Fileinput does not work with refile gem #359

jemminger opened this issue Apr 1, 2015 · 4 comments

Comments

@jemminger
Copy link

It appears that the call to e.stopPropagation() breaks the "direct" upload functionality of Refile. Refile is listening to the change event on document, and this call prevents it from bubbling.

Is there a reason why the change event should not bubble?

@ducman
Copy link
Collaborator

ducman commented Apr 1, 2015

From a quick look at the code, it stops because later on it fires a change.bs.fileinput event at the wrapper div level. It fires from the div that has this data attribute data-provides="fileinput".

I can see how third party plugins may not work if they're listen to this event at the document level for actual file inputs. For you, the only thing I can come up with is a workaround which is to remove the e.stopPropagation() and also the triggering of change.bs.fileinput event so that it bubble up. As for this plugin, @jasny may have some idea for a real solution so that it mitigate issues with third party plugins.

@jemminger
Copy link
Author

Yeah, for now I'm just running my own version with e.stopPropagation() commented out, and it seems to work as expected.

@jasny
Copy link
Owner

jasny commented Apr 2, 2015

Noted, have to think about it...

@oliveiragabriel07
Copy link

I have the same issue. Thanks for your suggestions. To keep original code unchanged I have overrided the original method like that:

$(function() {
  // Override jasny Fileinput.prototype.change method
  function change(e) {
    // copy/paste original function and comment out e.stopPropagation()
  }

  $(document).on('click.fileinput.data-api', '[data-provides="fileinput"]', function (e) {
    var self = $(this),
        input = self.find(':file'),
        plugin = self.data('bs.fileinput');

    input.off('change.bs.fileinput').on('change.bs.fileinput', $.proxy(change, plugin))
  })
});

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

No branches or pull requests

5 participants