Skip to content

Commit

Permalink
Dynamically get target element from the display element for checkbox cfs
Browse files Browse the repository at this point in the history
The "id" var is a global variable that's shared the whole page, for pages
that have multiple checkbox cfs, previously changing any display element
would always change the value of the last hidden checkbox input, which the
final id value points to.
  • Loading branch information
sunnavy committed Feb 6, 2024
1 parent 5afd223 commit 88f7683
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion share/html/Elements/EditCustomFieldSelect
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
var id = <% $name |n,j %>;
id = id.replace(/:/g,'\\:');
jQuery('#' + id + '-Display').change(function() {
jQuery('#' + id).val(jQuery(this).is(':checked') ? jQuery(this).data('checked-value') : jQuery(this).data('unchecked-value'));
var target = jQuery(this).attr('id').replace(/-Display$/, '').replace(/:/g,'\\:');
jQuery('#' + target).val(jQuery(this).is(':checked') ? jQuery(this).data('checked-value') : jQuery(this).data('unchecked-value'));
});
</script>
% } else {
Expand Down

0 comments on commit 88f7683

Please sign in to comment.