backbone.intercept
backbone.intercept copied to clipboard
Edge always submits forms
This is because
_interceptForms: function(e) {
if (e.target && e.target.action) { return; }
e.preventDefault();
},
returns when there's an action. In Edge, if there is no action defined on the form, it defaults to the current URL, therefore bypassing e.preventDefault().
hi @jeffijoe what is the expected behavior? that if the e.target.action is the same as the documents url and its edge, preventDefault()? or would that be too open?
The expected behavior is that Intercept will intercept form submissions, but only if they have no actions defined. In Edge, no action means action = current url, and so Intercept always bypasses it.
ok, but we wont change the action, the only thing I see which we can do would be to check if the action === url and then not return but continue to prevent, does that sound like a solution?
This is what I did to fix the issue on my end.
// In case Intercept does not catch things for forms (in Edge),
// use our own handler.
$('body').on('submit.interception', 'form', (e) => {
if ($(e.target).data('bypass')) return;
e.preventDefault();
});