$(document).on('click', '.edit-item', function(event) {
    let row_id = event.currentTarget.attributes['data-row'].value,
    data = dataIndex[
        dataIndex.findIndex(i => i.id === Number(row_id))
    ];
    $('.modal-body div:nth-child(1) input').attr('value', data.name)
    $('.modal-body div:nth-child(2) input').attr('value', data.category)
    $('.modal-body div:nth-child(3) #basicSelect').val(data.status)
    $('.modal-body div:nth-child(4) input').attr('value', data.price)
    $('.modal-body div:nth-child(5) input').attr('value', data.bju.mass)
    $('.modal-body div:nth-child(6) input').attr('value', data.bju.calories)
    $('.modal-body div:nth-child(7) input').attr('value', data.bju.proteins)
    $('.modal-body div:nth-child(8) input').attr('value', data.bju.fats)
    $('.modal-body div:nth-child(9) input').attr('value', data.bju.carbohydrates)
}
)
By Nik Destrave, 2021-05-30 21:59:31