initial commit

This commit is contained in:
Ray Elliott 2021-09-12 15:49:03 +01:00
parent d6ce6047ff
commit eafb9e174e
1 changed files with 8 additions and 1 deletions

View File

@ -6,6 +6,8 @@
var field_id = $(this).attr('id').replace(/[\[\]']+/g, '_'); // Field id, the true one field
var object_type = $(this).attr('data-object-type');
var query_args = $(this).attr('data-query-args');
var idSelector = $(this).attr('data-id-element');
var idElement = idSelector === undefined ? undefined : $(idSelector);
$(this).devbridgeAutocomplete(Object.assign({
serviceUrl: cmb_ajax_search.ajaxurl,
@ -75,9 +77,14 @@
}
} else {
// Singular
if (idElement !== undefined) {
$('input[name="' + field_name + '"]').val(suggestion.value).change();
idElement.val(suggestion.id);
} else {
$('input[name="' + field_name + '"]').val(suggestion.id).change();
}
}
}
},
cmb_ajax_search.options));