mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 15:05:42 +00:00
Merge pull request #38 from scott1702/feature/multi-page-forms-v2
Focus on new field when it gets added
This commit is contained in:
commit
7a9cc60cc0
@ -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…
x
Reference in New Issue
Block a user