Skip to content

Commit

Permalink
Fixed language switcher not working on MS Edge (#1213)
Browse files Browse the repository at this point in the history
Adapted the `form` attribute polyfill to trigger a submit if any button with a corresponding `form` attribute is clicked. This matches the behaviour of browsers that support the `form` attribute.
  • Loading branch information
TomOne authored and rhukster committed Sep 5, 2017
1 parent b73a48f commit a74cff2
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions themes/grav/js/form-attr.polyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,27 +51,29 @@
var form = this,
$fields = $('[form=' + this.id + ']');

$fields.filter('button, input').filter('[type=reset],[type=submit]').click(function() {
var type = this.type.toLowerCase();
if (type === 'reset') {
// reset form
form.reset();
// for elements outside form
$fields.each(function() {
this.value = this.defaultValue;
this.checked = this.defaultChecked;
}).filter('select').each(function() {
$(this).find('option').each(function() {
this.selected = this.defaultSelected;
$fields.filter('button, input')
.filter('[type=reset],[type=submit],[type=image],button')
.click(function() {
var type = this.type.toLowerCase();
if (type === 'reset') {
// reset form
form.reset();
// for elements outside form
$fields.each(function() {
this.value = this.defaultValue;
this.checked = this.defaultChecked;
}).filter('select').each(function() {
$(this).find('option').each(function() {
this.selected = this.defaultSelected;
});
});
});
} else if (type.match(/^submit|image$/i)) {
$(form).appendField({
name: this.name,
value: this.value
}).submit();
}
});
} else {
$(form).appendField({
name: this.name,
value: this.value
}).submit();
}
});
});
});

Expand Down

0 comments on commit a74cff2

Please sign in to comment.