如何使用对象值从数组中删除对象

时间:2014-10-21 09:36:03

标签: javascript jquery html

我看到了另一个答案,它不会发生在我身上 这是我的数组

[
  {
    "itemCode": "ITM-00000003",
    "label": "FRAME 1",
    "orderQty": "697",
    "rowId": 0
  },
  {
    "itemCode": "ITM-00000004",
    "label": "CCCLEN",
    "orderQty": "50",
    "rowId": 1
  }
]

我想使用' itemCode'删除对象 例如:itemCode =" ITM-00000004"

我正在使用

$("#iName").autocomplete({
    source: deletedItems,
    select: function (event, ui) {
        var rowid = ui.item.rowId;
        var itemCode = ui.item.itemCode;
        var itemName = ui.item.label;
        var orderQty = ui.item.orderQty;
        $("#invoiceDetailTbl tbody").append("<tr id=" + rowid + ">" + "<td>" + itemCode + "</td>" + "<td>" + itemName + "</td>" + "<td>" + orderQty + "</td>" + "<td>" + '<input type="text" class="deliverQty form-control input-sm" style="width: 100px;" placeholder="Deliver Qty" id="dqty">' + "</td>" + "<td>" + '<span class="glyphicon glyphicon-trash"></span>' + "</td>" + "</tr>");
        resetTableEvents();
        tableKeyUp();
        amountCalc();
        deletedItems = _.without(deletedItems, _.findWhere(deletedItems, { itemCode: itemCode }));
    }
});

但它不会发生 enter image description here

0 个答案:

没有答案