부트 스트랩에이 플러그인을 사용 중입니다. 및이 예제 https://jsfiddle.net/hh2zrt82/ 선택한 값을 가져 오려고하지만 선택할 수 없습니다. 어떻게 값을 가져올 수 있습니까? 도움을 청합니다. jQuery로bootstrap dualistbox 값을 선택하는 방법
var data = [
{
"id": 56,
"countryList_id": 10,
"port_iso": "India-pok"
},
{
"id": 57,
"countryList_id": 10,
"port_iso": "India-nmp"
},
{
"id": 58,
"countryList_id": 10,
"port_iso": "India-cop"
},
{
"id": 61,
"countryList_id": 2,
"port_iso": "Bangladesh-dhp"
},
{
"id": 62,
"countryList_id": 2,
"port_iso": "Bangladesh-brp"
},
{
"id": 63,
"countryList_id": 3,
"port_iso": "Singapore-pos"
},
{
"id": 64,
"countryList_id": 3,
"port_iso": "Singapore-SIN"
},
{
"id": 65,
"countryList_id": 3,
"port_iso": "Singapore-zxczx"
},
{
"id": 66,
"countryList_id": 2,
"port_iso": "Bangladesh-qewrqwe"
},
{
"id": 67,
"countryList_id": 3,
"port_iso": "Singapore-erer"
},
{
"id": 68,
"countryList_id": 3,
"port_iso": "Singapore-SIN"
}
];
var port_ids = [65,66,67];
var options = '';
for (var i = 0; i < data.length; i++) {
var a = 1;
for (var j = 0; j < port_ids.length; j++) {
// Appending "selected" attribute to the values which are already selected
if (port_ids[j] == data[i]["id"]) {
options += '<option value="' + data[i]["id"] + '" selected="selected">' + data[i]["port_iso"] + '</option>';
a = 0;
}
}
if (a == 1) {
options += '<option value="' + data[i]["id"] + '">' + data[i]["port_iso"] + '</option>';
}
}
$("select#country-of-operation-edit").empty().append(options);
$("#country-of-operation-edit").DualListBox();