1
var filterData = {
  items: []
};


$('.a').change(function(){

  if (this.checked == true) {

    const attrData = [];
    let filterItem = filterData.items.find(el =>
      el.taxonomy === this.name
    );

    if(filterItem) {
      filterItem.terms.push(this.value);
    } else {
      filterData.items.push({
        taxonomy: this.name,
        terms: [this.value],
      })
    }

    console.log(filterData.items);
  } else {
      let filterItemDel = filterData.items.find(el =>
      el.taxonomy === this.name
    );

    let iNum = filterItemDel.terms.indexOf(this.value);

    delete filterItemDel.terms[iNum];
  }
});

Записывать получаеться , а удалить заставить не могу.

1
  • что конкретно вы хотите удалить?
    – ymd
    16 авг 2018 в 21:35

1 ответ 1

1
//delete filterItemDel.terms[iNum];
filterItemDel.terms.splice(iNum, 1);

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.