Filling autoComplete field on the fly
Filling autoComplete field on the fly
Hi
I have such a field which needs to be populated based on user selection in another drop-down. I tried using the code below in the success event of an ajax call but the field is not populated. Please advise.
success: function (data) {
if (data != null && data != undefined && $.trim(data))
{
//alert('got here with data from ajax');
if (data.globalSubsPacksListViewModel != null) {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC"
];
editor.field('CustomerSubsPacks.Name').autocomplete({
source: availableTags
});
});
}
taken from https://jqueryui.com/autocomplete/
Js:
(...)
label: '@(lblo.lblName)*:',
name: 'CustomerSubsPacks.Name',
type: 'autoComplete',
opts: {
"source": [...],
Answers
Found a link that answers this https://datatables.net/forums/discussion/comment/150473/#Comment_150473
Hi
I now know how to set such a box with an array like so:
But how can I set the label/value pair of an autocomplete box to so label part has one bunch of values (db id's) and value another (some html)? The arrParamNames is populated using an $.each further up my code so maybe I can populated the box there. Thank you.
The aim is to have something similar to https://www.aspsnippets.com/Articles/Dynamically-Add-OPTIONs-to-DropDownList-SELECT-using-jQuery.aspx but this is for a normal select drop-down.
This works:
arrParamNames.push({label:somelabel, value:somevalue});