mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
focus on new field when added
This commit is contained in:
parent
ab79e5cd11
commit
bfe6ef0158
@ -39,5 +39,33 @@
|
||||
this._super();
|
||||
}
|
||||
});
|
||||
|
||||
// When new fields are added..
|
||||
$('.uf-field-editor .ss-gridfield-buttonrow .action').entwine({
|
||||
onclick: function (e) {
|
||||
this._super(e);
|
||||
|
||||
this.trigger('addnewinline');
|
||||
}
|
||||
});
|
||||
|
||||
$('.uf-field-editor').entwine({
|
||||
onmatch: function () {
|
||||
var self = this;
|
||||
|
||||
// When the 'Add field' button is clicked set a one time listener.
|
||||
// When the GridField is reloaded focus on the newly added field.
|
||||
this.on('addnewinline', function () {
|
||||
self.one('reload', function () {
|
||||
//If fieldgroup, focus on the start marker
|
||||
if ($('.uf-field-editor .ss-gridfield-item').last().attr('data-class') === 'EditableFieldGroupEnd') {
|
||||
$('.uf-field-editor .ss-gridfield-item').last().prev().find('.col-Title input').focus();
|
||||
} else {
|
||||
$('.uf-field-editor .ss-gridfield-item:last-child .col-Title input').focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}(jQuery));
|
||||
|
Loading…
Reference in New Issue
Block a user