Usuń wybrany element z Array w autouzupełnianiu jQuery
Mam tę tablicę,
var metrics = [
{
value: "1",
label: "Sold Listings",
desc: "sold_listings"
},
{
value: "10",
label: "New Pendings",
desc: "new_pendings"
},
{
value: "4",
label: "All Pendings",
desc: "all_pendings"
},
{
value: "2",
label: "New Listings",
desc: "new_listings"
},
{
value: "3",
label: "Active Listings",
desc: "active_listings"
}
];
To, co chciałem zrobić, to Wybrany przedmiot, na przykład wybiorę Aktywne aukcje, ten element powinien zostać usunięty z tablicy. Tak więc, gdy autouzupełnianie ponownie się wyświetli, nie pokaże wybranego elementu.
//My Idea of removing the item
$.each(metrics,function(i,val){
if(val.value == ui.item.value){
delete metrics[i];
}
});