Fix the input trigger API where a form element doesn't exist (#4033)
There are no `form` elements in the preview context of a form, so this adds an alternative selector to use when no common `form` elements are found for the Input Trigger API to use. Credit to @fansaien
This commit is contained in:
parent
d6b1b6e95d
commit
2dcd84c4f2
|
|
@ -511,7 +511,7 @@ class FormField
|
||||||
'data-trigger' => '[name="'.$fullTriggerField.'"]',
|
'data-trigger' => '[name="'.$fullTriggerField.'"]',
|
||||||
'data-trigger-action' => $triggerAction,
|
'data-trigger-action' => $triggerAction,
|
||||||
'data-trigger-condition' => $triggerCondition,
|
'data-trigger-condition' => $triggerCondition,
|
||||||
'data-trigger-closest-parent' => 'form'
|
'data-trigger-closest-parent' => 'form, div[data-control="formwidget"]'
|
||||||
];
|
];
|
||||||
|
|
||||||
return $attributes + $newAttributes;
|
return $attributes + $newAttributes;
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,17 @@
|
||||||
this.triggerConditionValue = (match) ? match : [""]
|
this.triggerConditionValue = (match) ? match : [""]
|
||||||
}
|
}
|
||||||
|
|
||||||
this.triggerParent = this.options.triggerClosestParent !== undefined
|
this.triggerParent = undefined
|
||||||
? $el.closest(this.options.triggerClosestParent)
|
if (this.options.triggerClosestParent !== undefined) {
|
||||||
: undefined
|
var closestParentElements = this.options.triggerClosestParent.split(',')
|
||||||
|
for (var i = 0; i < closestParentElements.length; i++) {
|
||||||
|
var $triggerElement = $el.closest(closestParentElements[i])
|
||||||
|
if ($triggerElement.length) {
|
||||||
|
this.triggerParent = $triggerElement
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
this.triggerCondition == 'checked' ||
|
this.triggerCondition == 'checked' ||
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue