$('#add').on('click', function () {
    var selector = $('#addModal');
    selector.find('.is-invalid').removeClass('is-invalid');
    selector.find('.error-message').remove();
    selector.modal('show')
    selector.find('form').trigger('reset');
});

$(document).on('click', '.edit', function () {
    commonAjax('GET', $('#getInfoRoute').val(), getDataEditRes, getDataEditRes, { 'id': $(this).data('id') });
});

function getDataEditRes(response) {
    var selector = $('#editModal');
    selector.find('.is-invalid').removeClass('is-invalid');
    selector.find('.error-message').remove();
    selector.find('input[name=id]').val(response.id)
    selector.find('input[name=name]').val(response.name)
    selector.find('input[name=title]').val(response.title)
    selector.find('textarea[name=summary]').text(response.summary)
    selector.find('textarea[name=content]').text(response.content)
    selector.find('select[name=status]').val(response.status)
    selector.modal('show')
}
