Hi Team,
We are using the crayons fw-select element to create a multi-select dropdown and then selecting some options using the below code.
function appendRoles(roles, presetdata) {
$('.adminSection').empty();
$('.agentSection').empty();
let adminSelect = generateMultiSelect('Admin Roles', 'Choose the choice for Admin', 'adminRoles', roles);
let agentSelect = generateMultiSelect('Agent Roles', 'Choose the choice for Agent', 'agentRoles', roles);
$('.adminSection').append(adminSelect);
$('.agentSection').append(agentSelect);
if (presetdata && 'adminRoles' in presetdata) {
setTimeout(() => {
$('.adminRoles').val(presetdata.adminRoles);
$('.agentRoles').val(presetdata.agentRoles);
}, 100);
}
}
function generateMultiSelect(label, placeholder, className, optionsArray) {
let multiSelect = `<fw-select label="${label}" class="${className}" placeholder="${placeholder}" multiple>`;
for (let items in optionsArray) {
multiSelect += `<fw-select-option value="${optionsArray[items].id}">${optionsArray[items].name}</fw-select-option>`
}
multiSelect += `</fw-select>`;
return multiSelect;
}
Initially, this above code worked as expected to select the options dynamically, but now it is not working.
When I set 300 instead of 100 in the setTimeout() method, it is working.
May I know the reason for this?
Thanks,
Akhil Moningi