mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #2000 from wilr/1640
FIX: IE8 does not bubble reset form events (Fixes #1640)
This commit is contained in:
commit
eedcacb256
@ -822,12 +822,15 @@ jQuery.noConflict();
|
|||||||
onmatch: function() {
|
onmatch: function() {
|
||||||
this.find('.ss-ui-button').click(function() {
|
this.find('.ss-ui-button').click(function() {
|
||||||
var form = this.form;
|
var form = this.form;
|
||||||
|
|
||||||
// forms don't natively store the button they've been triggered with
|
// forms don't natively store the button they've been triggered with
|
||||||
if(form) {
|
if(form) {
|
||||||
form.clickedButton = this;
|
form.clickedButton = this;
|
||||||
// Reset the clicked button shortly after the onsubmit handlers
|
// Reset the clicked button shortly after the onsubmit handlers
|
||||||
// have fired on the form
|
// have fired on the form
|
||||||
setTimeout(function() {form.clickedButton = null;}, 10);
|
setTimeout(function() {
|
||||||
|
form.clickedButton = null;
|
||||||
|
}, 10);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -942,33 +945,45 @@ jQuery.noConflict();
|
|||||||
* Generic search form in the CMS, often hooked up to a GridField results display.
|
* Generic search form in the CMS, often hooked up to a GridField results display.
|
||||||
*/
|
*/
|
||||||
$('.cms-search-form').entwine({
|
$('.cms-search-form').entwine({
|
||||||
|
onsubmit: function(e) {
|
||||||
onsubmit: function() {
|
|
||||||
// Remove empty elements and make the URL prettier
|
// Remove empty elements and make the URL prettier
|
||||||
var nonEmptyInputs = this.find(':input:not(:submit)').filter(function() {
|
var nonEmptyInputs,
|
||||||
|
url;
|
||||||
|
|
||||||
|
nonEmptyInputs = this.find(':input:not(:submit)').filter(function() {
|
||||||
// Use fieldValue() from jQuery.form plugin rather than jQuery.val(),
|
// Use fieldValue() from jQuery.form plugin rather than jQuery.val(),
|
||||||
// as it handles checkbox values more consistently
|
// as it handles checkbox values more consistently
|
||||||
var vals = $.grep($(this).fieldValue(), function(val) { return (val);});
|
var vals = $.grep($(this).fieldValue(), function(val) { return (val);});
|
||||||
return (vals.length);
|
return (vals.length);
|
||||||
});
|
});
|
||||||
var url = this.attr('action');
|
|
||||||
if(nonEmptyInputs.length) url = $.path.addSearchParams(url, nonEmptyInputs.serialize());
|
url = this.attr('action');
|
||||||
|
|
||||||
|
if(nonEmptyInputs.length) {
|
||||||
|
url = $.path.addSearchParams(url, nonEmptyInputs.serialize());
|
||||||
|
}
|
||||||
|
|
||||||
var container = this.closest('.cms-container');
|
var container = this.closest('.cms-container');
|
||||||
container.find('.cms-edit-form').tabs('select',0); //always switch to the first tab (list view) when searching
|
container.find('.cms-edit-form').tabs('select',0); //always switch to the first tab (list view) when searching
|
||||||
container.loadPanel(url);
|
container.loadPanel(url, "", {}, true);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets are processed on the serverside, so need to trigger a submit.
|
* Reset button handler. IE8 does not bubble reset events to
|
||||||
*/
|
*/
|
||||||
onreset: function(e) {
|
$(".cms-search-form button[type=reset]").entwine({
|
||||||
this.clearForm();
|
onclick: function(e) {
|
||||||
this.submit();
|
e.preventDefault();
|
||||||
}
|
|
||||||
|
|
||||||
});
|
var form = $(this).parents('form');
|
||||||
|
|
||||||
|
form.clearForm();
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows to lazy load a panel, by leaving it empty
|
* Allows to lazy load a panel, by leaving it empty
|
||||||
|
Loading…
x
Reference in New Issue
Block a user