Merge pull request #447 from oilee80/master

Have JS work across different Form IDs
This commit is contained in:
Dylan Wagstaff 2019-12-05 15:09:57 +13:00 committed by GitHub
commit 3f8607ffbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -8,7 +8,8 @@
onchange: function() {
// TODO Data binding between two fields
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.refresh();
field.trigger('change');
@ -21,8 +22,9 @@
*/
$('.TreeDropdownField.SubsitesTreeDropdownField').entwine({
getAttributes() {
const fieldName = this.attr('id').replace('Form_EditForm_', '');
const subsiteID = $('#Form_EditForm_' + fieldName + '_SubsiteID option:selected').val();
const formId = this.closest('form').attr('id');
const fieldName = this.attr('id').replace(formId + '_', '');
const subsiteID = $('#' + formId + '_' + fieldName + '_SubsiteID option:selected').val();
let attributes = this._super();
attributes.data.urlTree += "?" + fieldName + "_SubsiteID=" + subsiteID;