$(document).ready(function() { tampil_template(); $('#table_template_sertifikat').DataTable(); function tampil_template() { $.ajax({ type: 'ajax', url: window.location.origin + '/mbkm/admin/get_template/', async: false, dataType: 'json', success: function (data) { console.log(data); var html = ''; for (var i = 0; i < data.length; i++) { html += '' + '' + (i + 1) + '' + '' + data[i].judul + '' + '' + data[i].tujuan + '' + '' + data[i].isi + '' + '' + data[i].ttd + '' + '' + '' + '' + ''; } $('#show_data').html(html); } }); } $('#show_data').on('click', '.tombol-edit-isi', function () { var id = $(this).attr('data-id'); // console.log(id); $.ajax({ type: 'GET', url: window.location.origin + '/mbkm/admin/get_templatebyid/', dataType: 'json', data: { id: id, }, success: function (data) { // console.log(data[0].id); $.each(data, function() { var base_url = window.location.origin; $('#modal-edit-template').modal('show'); $('.form-edit-template').attr('action', base_url + '/mbkm/admin/edit_template/' + data[0].id); $('#judul').val(data[0].judul); $('#tujuan').val(data[0].tujuan); $('#isi').val(data[0].isi); $('#ttd').val(data[0].ttd); }); } }); return false; }); $('#create-user').on('click', function() { $('#modal-input').modal('show'); $('.form-input').attr('action', ''); $('.form-input').trigger("reset"); }); }); var coll = document.getElementsByClassName("collapsible"); var i; for (i = 0; i < coll.length; i++) { coll[i].addEventListener("click", function() { this.classList.toggle("activee"); var content = this.nextElementSibling; if (content.style.maxHeight){ content.style.maxHeight = null; } else { content.style.maxHeight = content.scrollHeight + "px"; } }); }