bootstrap
bootstrap copied to clipboard
Fileinput does not work with refile gem
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?
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.
Yeah, for now I'm just running my own version with e.stopPropagation()
commented out, and it seems to work as expected.
Noted, have to think about it...
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))
})
});