'Select2 doesn't automatically set selected value on CentOS 7
I have a select2 to display list of timezone and automatically set selected value, codes below works properly in development environment (ASP MVC Net Core 3.1), Visual Studio 2019, but it doesn't automatically set selected value when it runs on CentOS 7, strange for me, anybody can give me an advice?
$.ajax({
headers: {
api_key: '@PTX.Models.AppSettingsModel.Application.API_Key',
api_secret: '@PTX.Models.AppSettingsModel.Application.API_Secret'
},
type: 'GET',
url: getDeploymentPath() + '/User/Timezone/',
dataType: 'json'
}).done(function (data)
{
result = $.map(data, function (x)
{
return {
id: x.id,
text: x.text
};
});
$("#timezone").select2({
data: result,
placeholder: "Select timezone",
escapeMarkup: function (markup)
{
return markup;
}
});
$('#timezone').val(_timezone_id);
$('#timezone').select2().trigger('change');
// Have tried below, but no luck :(
//$("#timezone").select2('data', { id: _timezone_id, text: _timezone_text });
//$('#timezone').val(_timezone_id).trigger('change');
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
