@push('crud_fields_scripts')
<script type="text/javascript">
jQuery('document').ready(function ($) {
+
var triggersWhenChange = function (f) {
var form;
var prefix = '';
});
$(form).find('[data-when]').removeClass('when-visible').each(function () {
+ var element = $(this);
if ($(this).data('when-normalized') === undefined) {
$(this).data('when-normalized', normalizeWhen($(this).data('when')));
}
var match = true;
var order = 1000;
$.each(when, function (property, conditions) {
- var fname = prefix + property;
- var e = $(form).find('[name="' + fname + '"]');
+ var e = findCloserInput(element, property);
+ if ($(element).is('[bp-field-name]') && $(element).attr('bp-field-name').indexOf('area_1') >= 0) {
+ console.log(property, element, e);
+ }
var val;
+ if ($(e).length === 0) {
+ match = false;
+ return false;
+ }
if ($(e).length === 1) {
try {
val = $(e).val().toString();
}
}
}
+
var matchproperty = false;
$.each(conditions, function (k, condition) {
if (condition.id === val) {
return value && typeof value === 'object' && value.constructor === Object;
}
+ function findCloserInput(element, inputName) {
+
+ let siblings = $(element).siblings('[data-name="' + inputName + '"]');
+ if (siblings.length === 0) {
+ let parent = $(element).parent();
+ if (parent === null || $(parent).length === 0) {
+ return null;
+ }
+ return findCloserInput(parent, inputName);
+ }
+ let res = $(siblings).find('[name="' + inputName + '"]');
+ if (res.length === 0) {
+ res = $(siblings).find('[name$="___' + inputName + '"]');
+ }
+ return res;
+ }
+
});
</script>