<script type="text/javascript">
	

	$(document).ready(function(){
		loadData()
	})


	
	function loadData() {
		$('#datatable').DataTable({
			"pageLength": 10,
			"serverSide": true,
			"processing": true,
			"scrollX": true,
			"order": [
				[0, "desc"]
			],
			"columnDefs": [
				{
					targets: [0,2],
					className: "text-center"
				},
				{
					orderable: false,
					targets: [1,2]
				},
				{
					width: '5%',
					targets: [0]
				},
				{
					width: '20%',
					targets: [2]
				},
				{
					width: '75%',
					targets: [1]
				}
			],
			"ajax": {
				url: baseUrl + 'unit/get-all-data',
				type: 'POST',
				data: {
				},
			},
			"columns": [{
					data: "no"
				},
				{
					data: "name"
				},
				{
					data: "option"
				},
			],
			"destroy": true
		}); // End of DataTable
	}



	$("#btn_add").on('click',function(e){
		e.preventDefault()
		
		$("#modal_add").modal('show')
		// loading
		$("#modal_add").find('.modal-content').load(baseUrl+'unit/add')
	})

	$("#datatable").delegate(".datatable-edit", "click", function (e) {
		  var url = $(this).attr("data-link");
		  e.preventDefault()
			
			$("#modal_edit").modal('show')
			// loading
			$("#modal_edit").find('.modal-content').load(url)


	})

</script>