mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Have JS work accross different Form IDs
Default JS only works on `EditForm`
This commit is contained in:
parent
9654da8966
commit
5ea144d250
@ -8,7 +8,8 @@
|
|||||||
onchange: function() {
|
onchange: function() {
|
||||||
// TODO Data binding between two fields
|
// TODO Data binding between two fields
|
||||||
const name = this.attr('name').replace('_SubsiteID', '');
|
const name = this.attr('name').replace('_SubsiteID', '');
|
||||||
let field = $('#Form_EditForm_' + name).first();
|
const formId = this.closest('form').attr('id');
|
||||||
|
let field = $('#' + formId + '_' + name).first();
|
||||||
field.setValue(0);
|
field.setValue(0);
|
||||||
field.refresh();
|
field.refresh();
|
||||||
field.trigger('change');
|
field.trigger('change');
|
||||||
@ -21,8 +22,9 @@
|
|||||||
*/
|
*/
|
||||||
$('.TreeDropdownField.SubsitesTreeDropdownField').entwine({
|
$('.TreeDropdownField.SubsitesTreeDropdownField').entwine({
|
||||||
getAttributes() {
|
getAttributes() {
|
||||||
const fieldName = this.attr('id').replace('Form_EditForm_', '');
|
const formId = this.closest('form').attr('id');
|
||||||
const subsiteID = $('#Form_EditForm_' + fieldName + '_SubsiteID option:selected').val();
|
const fieldName = this.attr('id').replace(formId + '_', '');
|
||||||
|
const subsiteID = $('#' + formId + '_' + fieldName + '_SubsiteID option:selected').val();
|
||||||
|
|
||||||
let attributes = this._super();
|
let attributes = this._super();
|
||||||
attributes.data.urlTree += "?" + fieldName + "_SubsiteID=" + subsiteID;
|
attributes.data.urlTree += "?" + fieldName + "_SubsiteID=" + subsiteID;
|
||||||
|
Loading…
Reference in New Issue
Block a user