mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Improved focus handling in GridField
This commit is contained in:
parent
dc83ace928
commit
bd1f652fe9
@ -6,7 +6,10 @@
|
||||
* @param {successCallback} callback to call after reloading succeeded.
|
||||
*/
|
||||
reload: function(ajaxOpts, successCallback) {
|
||||
var self = this, form = this.closest('form'), data = form.find(':input').serializeArray();
|
||||
var self = this, form = this.closest('form'),
|
||||
focusedElName = this.find(':input:focus').attr('name'), // Save focused element for restoring after refresh
|
||||
data = form.find(':input').serializeArray();
|
||||
|
||||
if(!ajaxOpts) ajaxOpts = {};
|
||||
if(!ajaxOpts.data) ajaxOpts.data = [];
|
||||
ajaxOpts.data = ajaxOpts.data.concat(data);
|
||||
@ -30,6 +33,10 @@
|
||||
// of the executing method. Means that it doesn't retrigger the onmatch() on the main container.
|
||||
self.empty().append($(data).children());
|
||||
|
||||
// Refocus previously focused element. Useful e.g. for finding+adding
|
||||
// multiple relationships via keyboard.
|
||||
if(focusedElName) self.find(':input[name="' + focusedElName + '"]').focus();
|
||||
|
||||
form.removeClass('loading');
|
||||
if(successCallback) successCallback.apply(this, arguments);
|
||||
self.trigger('reload', self);
|
||||
|
Loading…
x
Reference in New Issue
Block a user