答案 0 :(得分:1)
您可以使用此
WOSkuSelectTemplate.find('select').find("option[value = '" + element.nProductTypeID + "']").attr("selected", "selected");
答案 1 :(得分:0)
它"脏"但你可以这样做:
regY

// [test code]
var actionsList = [{
nProductTypeID: 2,
nID: 1,
cTaskNumber: 3,
nQty: 10,
nActionTypeID: 75,
cFrom: "John",
cTo: "Doe",
dRequired: "true",
bCompleted: 0
}];
// [/test code]
$(document).ready(function() {
// other code...
var actionsListHTML = "";
if(actionsList) { //if there are actions entries
actionsList.forEach(function(element) {
var clonedDivWithSelect = $("#WOSkuSelectTemplate").clone();
clonedDivWithSelect.find("option[value=\"" + element.nProductTypeID + "\"]").attr("selected", "selected");
actionsListHTML += "<tr>";
actionsListHTML += "<td>" + element.nID + "</td>";
actionsListHTML += "<td>" + element.cTaskNumber + "</td>";
actionsListHTML += "<td>" + clonedDivWithSelect.html() + "</td>";
actionsListHTML += "<td>" + element.nQty + "</td>";
actionsListHTML += "<td>" + element.nActionTypeID + "</td>";
actionsListHTML += "<td>" + element.cFrom + "</td>";
actionsListHTML += "<td>" + element.cTo + "</td>";
actionsListHTML += "<td>" + element.dRequired + "</td>";
actionsListHTML += "<td><input type='checkbox'" + ((element.bCompleted == 0) ? "" : "checked") + " disabled></td>";
actionsListHTML += "</tr>";
});
}
$("#workOrderActionsListBody").html(actionsListHTML);
// other code...
});
&#13;
P.S。是啊Agam Banga按时击败我选择部分。