(Codeigniter) Ajax CRUD menggunakan modals Bootstrap dan DataTables dengan Upload Gambar
08.58
Add Comment
Berikut ini bahan-bahan yang kita butuhkan dan silahkan download :
Langkah 3. Setelah folder asset di buat, sekarang buat 1 folder lagi dan beri nama upload yang akan di gunakan sebagai penyimpanan file gambar. Jadikan folder ini dengan 777 permission settings.
Langkah 4. Mengkonfigurasi routes.php untuk default controller.
config/routes.php
config/config.php
dan jangan lupa untuk konfigurasi database nya sesuai dengan database anda
config/database.php
Langkah 6. Buat Person_model.php di folder models
Demo
Download source code :
Download
Semoga bermanfaat..!
Mohon koreksi jika ada kesalahan..!
- PHP+ MySQL atau menggunakan XAMPP –> Download
- Codeigniter 3.1.0 –> Download
- jQuery 2.1.4 –> Download
- Twitter Bootstrap 3.3.7 –> Download
- Bootstrap-datepicker 1.6.1 –> Download
- DataTables 1.10.12 –> Download
Langkah 2. Copy Codeigniter yang sudah anda ke direktori htdocs web Anda. dan buatlah folder assets untuk direktori CodeIgniter mencakup semua javascript dan css library seperti ini.create
database
demo
;
use
demo
;
CREATE
TABLE
`persons` (
`id`
int
(11) unsigned
NOT
NULL
AUTO_INCREMENT,
`firstName`
varchar
(100)
DEFAULT
NULL
,
`lastName`
varchar
(100)
DEFAULT
NULL
,
`gender` enum(
'male'
,
'female'
)
DEFAULT
NULL
,
`address`
varchar
(200)
DEFAULT
NULL
,
`dob`
date
DEFAULT
NULL
,
`photo`
varchar
(255)
DEFAULT
NULL
,
PRIMARY
KEY
(`id`)
) ENGINE=InnoDB
DEFAULT
CHARSET=utf8;
-- example data persons
INSERT
INTO
`persons` (`id`, `firstName`, `lastName`, `gender`, `address`, `dob`)
VALUES
(1,
'Airi'
,
'Satou'
,
'female'
,
'Tokyo'
,
'1964-03-04'
),
(2,
'Garrett'
,
'Winters'
,
'male'
,
'Tokyo'
,
'1988-09-02'
),
(3,
'John'
,
'Doe'
,
'male'
,
'Kansas'
,
'1972-11-02'
),
(4,
'Tatyana'
,
'Fitzpatrick'
,
'male'
,
'London'
,
'1989-01-01'
),
(5,
'Quinn'
,
'Flynn'
,
'male'
,
'Edinburgh'
,
'1977-03-24'
);
Langkah 3. Setelah folder asset di buat, sekarang buat 1 folder lagi dan beri nama upload yang akan di gunakan sebagai penyimpanan file gambar. Jadikan folder ini dengan 777 permission settings.
Langkah 4. Mengkonfigurasi routes.php untuk default controller.
config/routes.php
Langkah 5. Untuk codeigniter versi 3.0.3 atau yang lebih baru base_url harus dikonfigurasi secara manual. Anda lihat seperti dibawah ini :$route
[
'default_controller'
] =
'person'
;
$route
[
'404_override'
] =
''
;
$route
[
'translate_uri_dashes'
] = FALSE;
config/config.php
dan jangan lupa untuk konfigurasi database nya sesuai dengan database anda
config/database.php
Langkah 6. Buat Person_model.php di folder models
Langkah 7. Buat Person.php di folder controllers<?php defined(
'BASEPATH'
) OR
exit
(
'No direct script access allowed'
);
class
Person_model
extends
CI_Model {
var
$table
=
'persons'
;
var
$column_order
=
array
(
'firstname'
,
'lastname'
,
'gender'
,
'address'
,
'dob'
,null);
//set column field database for datatable orderable var $column_search = array('firstname','lastname','address'); //set column field database for datatable searchable just firstname , lastname , address are searchable var $order = array('id' => 'desc'); // default order
public
function
__construct()
{
parent::__construct();
$this
->load->database();
}
private
function
_get_datatables_query()
{
$this
->db->from(
$this
->table);
$i
= 0;
foreach
(
$this
->column_search
as
$item
)
// loop column
{
if
(
$_POST
[
'search'
][
'value'
])
// if datatable send POST for search
{
if
(
$i
===0)
// first loop
{
$this
->db->group_start();
// open bracket. query Where with OR clause better with bracket. because maybe can combine with other WHERE with AND.
$this
->db->like(
$item
,
$_POST
[
'search'
][
'value'
]);
}
else
{
$this
->db->or_like(
$item
,
$_POST
[
'search'
][
'value'
]);
}
if
(
count
(
$this
->column_search) - 1 ==
$i
)
//last loop
$this
->db->group_end();
//close bracket
}
$i
++;
}
if
(isset(
$_POST
[
'order'
]))
// here order processing
{
$this
->db->order_by(
$this
->column_order[
$_POST
[
'order'
][
'0'
][
'column'
]],
$_POST
[
'order'
][
'0'
][
'dir'
]);
}
else
if
(isset(
$this
->order))
{
$order
=
$this
->order;
$this
->db->order_by(key(
$order
),
$order
[key(
$order
)]);
}
}
function
get_datatables()
{
$this
->_get_datatables_query();
if
(
$_POST
[
'length'
] != -1)
$this
->db->limit(
$_POST
[
'length'
],
$_POST
[
'start'
]);
$query
=
$this
->db->get();
return
$query
->result();
}
function
count_filtered()
{
$this
->_get_datatables_query();
$query
=
$this
->db->get();
return
$query
->num_rows();
}
public
function
count_all()
{
$this
->db->from(
$this
->table);
return
$this
->db->count_all_results();
}
public
function
get_by_id(
$id
)
{
$this
->db->from(
$this
->table);
$this
->db->where(
'id'
,
$id
);
$query
=
$this
->db->get();
return
$query
->row();
}
public
function
save(
$data
)
{
$this
->db->insert(
$this
->table,
$data
);
return
$this
->db->insert_id();
}
public
function
update(
$where
,
$data
)
{
$this
->db->update(
$this
->table,
$data
,
$where
);
return
$this
->db->affected_rows();
}
public
function
delete_by_id(
$id
)
{
$this
->db->where(
'id'
,
$id
);
$this
->db->
delete
(
$this
->table);
}
}
Langkah 8. Buat person_view.php di folder views<?php defined(
'BASEPATH'
) OR
exit
(
'No direct script access allowed'
);
class
Person
extends
CI_Controller {
public
function
__construct() { parent::__construct();
$this
->load->model(
'person_model'
,
'person'
);
}
public
function
index()
{
$this
->load->helper(
'url'
);
$this
->load->view(
'person_view'
);
}
public
function
ajax_list()
{
$this
->load->helper(
'url'
);
$list
=
$this
->person->get_datatables();
$data
=
array
();
$no
=
$_POST
[
'start'
];
foreach
(
$list
as
$person
) {
$no
++;
$row
=
array
();
$row
[] =
$person
->firstName;
$row
[] =
$person
->lastName;
$row
[] =
$person
->gender;
$row
[] =
$person
->address;
$row
[] =
$person
->dob;
if
(
$person
->photo)
$row
[] =
'<a href="'
.base_url(
'upload/'
.
$person
->photo).
'" target="_blank"><img src="'
.base_url(
'upload/'
.
$person
->photo).
'" class="img-responsive" /></a>'
;
else
$row
[] =
'(No photo)'
;
//add html for action
$row
[] =
'<a class="btn btn-sm btn-primary" href="javascript:void(0)" title="Edit" onclick="edit_person('
."
'".$person->id."'
".')"
><i
class
=
"glyphicon glyphicon-pencil"
></i> Edit</a>
<a
class
=
"btn btn-sm btn-danger"
href=
"javascript:void(0)"
title=
"Hapus"
onclick=
"delete_person('."
'
".$person->id."
'".'
)"><i
class
=
"glyphicon glyphicon-trash"
></i>
Delete
</a>';
$data
[] =
$row
;
}
$output
=
array
(
"draw"
=>
$_POST
[
'draw'
],
"recordsTotal"
=>
$this
->person->count_all(),
"recordsFiltered"
=>
$this
->person->count_filtered(),
"data"
=>
$data
,
);
//output to json format
echo
json_encode(
$output
);
}
public
function
ajax_edit(
$id
)
{
$data
=
$this
->person->get_by_id(
$id
);
$data
->dob = (
$data
->dob ==
'0000-00-00'
) ?
''
:
$data
->dob;
// if 0000-00-00 set tu empty for datepicker compatibility
echo
json_encode(
$data
);
}
public
function
ajax_add()
{
$this
->_validate();
$data
=
array
(
'firstName'
=>
$this
->input->post(
'firstName'
),
'lastName'
=>
$this
->input->post(
'lastName'
),
'gender'
=>
$this
->input->post(
'gender'
),
'address'
=>
$this
->input->post(
'address'
),
'dob'
=>
$this
->input->post(
'dob'
),
);
if
(!
empty
(
$_FILES
[
'photo'
][
'name'
]))
{
$upload
=
$this
->_do_upload();
$data
[
'photo'
] =
$upload
;
}
$insert
=
$this
->person->save(
$data
);
echo
json_encode(
array
(
"status"
=> TRUE));
}
public
function
ajax_update()
{
$this
->_validate();
$data
=
array
(
'firstName'
=>
$this
->input->post(
'firstName'
),
'lastName'
=>
$this
->input->post(
'lastName'
),
'gender'
=>
$this
->input->post(
'gender'
),
'address'
=>
$this
->input->post(
'address'
),
'dob'
=>
$this
->input->post(
'dob'
),
);
if
(
$this
->input->post(
'remove_photo'
))
// if remove photo checked
{
if
(
file_exists
(
'upload/'
.
$this
->input->post(
'remove_photo'
)) &&
$this
->input->post(
'remove_photo'
))
unlink(
'upload/'
.
$this
->input->post(
'remove_photo'
));
$data
[
'photo'
] =
''
;
}
if
(!
empty
(
$_FILES
[
'photo'
][
'name'
]))
{
$upload
=
$this
->_do_upload();
//delete file
$person
=
$this
->person->get_by_id(
$this
->input->post(
'id'
));
if
(
file_exists
(
'upload/'
.
$person
->photo) &&
$person
->photo)
unlink(
'upload/'
.
$person
->photo);
$data
[
'photo'
] =
$upload
;
}
$this
->person->update(
array
(
'id'
=>
$this
->input->post(
'id'
)),
$data
);
echo
json_encode(
array
(
"status"
=> TRUE));
}
public
function
ajax_delete(
$id
)
{
//delete file
$person
=
$this
->person->get_by_id(
$id
);
if
(
file_exists
(
'upload/'
.
$person
->photo) &&
$person
->photo)
unlink(
'upload/'
.
$person
->photo);
$this
->person->delete_by_id(
$id
);
echo
json_encode(
array
(
"status"
=> TRUE));
}
private
function
_do_upload()
{
$config
[
'upload_path'
] =
'upload/'
;
$config
[
'allowed_types'
] =
'gif|jpg|png'
;
$config
[
'max_size'
] = 100;
//set max size allowed in Kilobyte
$config
[
'max_width'
] = 1000;
// set max width image allowed
$config
[
'max_height'
] = 1000;
// set max height allowed
$config
[
'file_name'
] =
round
(microtime(true) * 1000);
//just milisecond timestamp fot unique name
$this
->load->library(
'upload'
,
$config
);
if
(!
$this
->upload->do_upload(
'photo'
))
//upload and validate
{
$data
[
'inputerror'
][] =
'photo'
;
$data
[
'error_string'
][] =
'Upload error: '
.
$this
->upload->display_errors(
''
,
''
);
//show ajax error
$data
[
'status'
] = FALSE;
echo
json_encode(
$data
);
exit
();
}
return
$this
->upload->data(
'file_name'
);
}
private
function
_validate()
{
$data
=
array
();
$data
[
'error_string'
] =
array
();
$data
[
'inputerror'
] =
array
();
$data
[
'status'
] = TRUE;
if
(
$this
->input->post(
'firstName'
) ==
''
)
{
$data
[
'inputerror'
][] =
'firstName'
;
$data
[
'error_string'
][] =
'First name is required'
;
$data
[
'status'
] = FALSE;
}
if
(
$this
->input->post(
'lastName'
) ==
''
)
{
$data
[
'inputerror'
][] =
'lastName'
;
$data
[
'error_string'
][] =
'Last name is required'
;
$data
[
'status'
] = FALSE;
}
if
(
$this
->input->post(
'dob'
) ==
''
)
{
$data
[
'inputerror'
][] =
'dob'
;
$data
[
'error_string'
][] =
'Date of Birth is required'
;
$data
[
'status'
] = FALSE;
}
if
(
$this
->input->post(
'gender'
) ==
''
)
{
$data
[
'inputerror'
][] =
'gender'
;
$data
[
'error_string'
][] =
'Please select gender'
;
$data
[
'status'
] = FALSE;
}
if
(
$this
->input->post(
'address'
) ==
''
)
{
$data
[
'inputerror'
][] =
'address'
;
$data
[
'error_string'
][] =
'Addess is required'
;
$data
[
'status'
] = FALSE;
}
if
(
$data
[
'status'
] === FALSE)
{
echo
json_encode(
$data
);
exit
();
}
}
}
Contoh demo :<!DOCTYPE html>
<html>
<head>
<meta charset=
"utf-8"
>
<meta http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<title>Ajax CRUD with Bootstrap modals
and
Datatables with Image Upload</title>
<link href=
"<?php echo base_url('assets/bootstrap/css/bootstrap.min.css')?>"
rel=
"stylesheet"
>
<link href=
"<?php echo base_url('assets/datatables/css/dataTables.bootstrap.min.css')?>"
rel=
"stylesheet"
>
<link href=
"<?php echo base_url('assets/bootstrap-datepicker/css/bootstrap-datepicker3.min.css')?>"
rel=
"stylesheet"
>
<!-- HTML5 shim
and
Respond.js
for
IE8 support of HTML5 elements
and
media queries -->
<!-- WARNING: Respond.js doesn't work
if
you view the page via file:
// -->
<!--[
if
lt IE 9]>
<![
endif
]-->
</head>
<body>
<div
class
=
"container"
>
<h1 style=
"font-size:20pt"
>Ajax CRUD with Bootstrap modals
and
Datatables with Image Upload</h1>
<h3>Person Data</h3>
<br />
<button
class
=
"btn btn-success"
onclick=
"add_person()"
><i
class
=
"glyphicon glyphicon-plus"
></i> Add Person</button>
<button
class
=
"btn btn-default"
onclick=
"reload_table()"
><i
class
=
"glyphicon glyphicon-refresh"
></i> Reload</button>
<br />
<br />
<table id=
"table"
class
=
"table table-striped table-bordered"
cellspacing=
"0"
width=
"100%"
>
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Address</th>
<th>
Date
of Birth</th>
<th>Photo</th>
<th style=
"width:150px;"
>Action</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Gender</th>
<th>Address</th>
<th>
Date
of Birth</th>
<th>Photo</th>
<th>Action</th>
</tr>
</tfoot>
</table>
</div>
<script src=
"<?php echo base_url('assets/jquery/jquery-3.1.0.min.js')?>"
></script>
<script src=
"<?php echo base_url('assets/bootstrap/js/bootstrap.min.js')?>"
></script>
<script src=
"<?php echo base_url('assets/datatables/js/jquery.dataTables.min.js')?>"
></script>
<script src=
"<?php echo base_url('assets/datatables/js/dataTables.bootstrap.min.js')?>"
></script>
<script src=
"<?php echo base_url('assets/bootstrap-datepicker/js/bootstrap-datepicker.min.js')?>"
></script>
<script type=
"text/javascript"
>
var
save_method;
//for save method string
var
table;
var
base_url =
'<?php echo base_url();?>'
;
$(document).ready(
function
() {
//datatables
table = $(
'#table'
).DataTable({
"processing"
: true,
//Feature control the processing indicator.
"serverSide"
: true,
//Feature control DataTables' server-side processing mode.
"order"
: [],
//Initial no order.
// Load data for the table's content from an Ajax source
"ajax"
: {
"url"
:
"<?php echo site_url('person/ajax_list')?>"
,
"type"
:
"POST"
},
//Set column definition initialisation properties.
"columnDefs"
: [
{
"targets"
: [ -1 ],
//last column
"orderable"
: false,
//set not orderable
},
{
"targets"
: [ -2 ],
//2 last column (photo)
"orderable"
: false,
//set not orderable
},
],
});
//datepicker
$(
'.datepicker'
).datepicker({
autoclose: true,
format:
"yyyy-mm-dd"
,
todayHighlight: true,
orientation:
"top auto"
,
todayBtn: true,
todayHighlight: true,
});
//set input/textarea/select event when change value, remove class error and remove text help block
$(
"input"
).change(
function
(){
$(this).parent().parent().removeClass(
'has-error'
);
$(this).next().
empty
();
});
$(
"textarea"
).change(
function
(){
$(this).parent().parent().removeClass(
'has-error'
);
$(this).next().
empty
();
});
$(
"select"
).change(
function
(){
$(this).parent().parent().removeClass(
'has-error'
);
$(this).next().
empty
();
});
});
function
add_person()
{
save_method =
'add'
;
$(
'#form'
)[0].reset();
// reset form on modals
$(
'.form-group'
).removeClass(
'has-error'
);
// clear error class
$(
'.help-block'
).
empty
();
// clear error string
$(
'#modal_form'
).modal(
'show'
);
// show bootstrap modal
$(
'.modal-title'
).text(
'Add Person'
);
// Set Title to Bootstrap modal title
$(
'#photo-preview'
).hide();
// hide photo preview modal
$(
'#label-photo'
).text(
'Upload Photo'
);
// label photo upload
}
function
edit_person(id)
{
save_method =
'update'
;
$(
'#form'
)[0].reset();
// reset form on modals
$(
'.form-group'
).removeClass(
'has-error'
);
// clear error class
$(
'.help-block'
).
empty
();
// clear error string
//Ajax Load data from ajax
$.ajax({
url :
"<?php echo site_url('person/ajax_edit')?>/"
+ id,
type:
"GET"
,
dataType:
"JSON"
,
success:
function
(data)
{
$(
'[name="id"]'
).val(data.id);
$(
'[name="firstName"]'
).val(data.firstName);
$(
'[name="lastName"]'
).val(data.lastName);
$(
'[name="gender"]'
).val(data.gender);
$(
'[name="address"]'
).val(data.address);
$(
'[name="dob"]'
).datepicker(
'update'
,data.dob);
$(
'#modal_form'
).modal(
'show'
);
// show bootstrap modal when complete loaded
$(
'.modal-title'
).text(
'Edit Person'
);
// Set title to Bootstrap modal title
$(
'#photo-preview'
).show();
// show photo preview modal
if
(data.photo)
{
$(
'#label-photo'
).text(
'Change Photo'
);
// label photo upload
$(
'#photo-preview div'
).html(
'<img src="'
+base_url+
'upload/'
+data.photo+
'" class="img-responsive">'
);
// show photo
$(
'#photo-preview div'
).append(
'<input type="checkbox" name="remove_photo" value="'
+data.photo+
'"/> Remove photo when saving'
);
// remove photo
}
else
{
$(
'#label-photo'
).text(
'Upload Photo'
);
// label photo upload
$(
'#photo-preview div'
).text(
'(No photo)'
);
}
},
error:
function
(jqXHR, textStatus, errorThrown)
{
alert(
'Error get data from ajax'
);
}
});
}
function
reload_table()
{
table.ajax.reload(null,false);
//reload datatable ajax
}
function
save()
{
$(
'#btnSave'
).text(
'saving...'
);
//change button text
$(
'#btnSave'
).attr(
'disabled'
,true);
//set button disable
var
url;
if
(save_method ==
'add'
) {
url =
"<?php echo site_url('person/ajax_add')?>"
;
}
else
{
url =
"<?php echo site_url('person/ajax_update')?>"
;
}
// ajax adding data to database
var
formData =
new
FormData($(
'#form'
)[0]);
$.ajax({
url : url,
type:
"POST"
,
data: formData,
contentType: false,
processData: false,
dataType:
"JSON"
,
success:
function
(data)
{
if
(data.status)
//if success close modal and reload ajax table
{
$(
'#modal_form'
).modal(
'hide'
);
reload_table();
}
else
{
for
(
var
i = 0; i < data.inputerror.length; i++)
{
$(
'[name="'
+data.inputerror[i]+
'"]'
).parent().parent().addClass(
'has-error'
);
//select parent twice to select div form-group class and add has-error class
$(
'[name="'
+data.inputerror[i]+
'"]'
).next().text(data.error_string[i]);
//select span help-block class set text error string
}
}
$(
'#btnSave'
).text(
'save'
);
//change button text
$(
'#btnSave'
).attr(
'disabled'
,false);
//set button enable
},
error:
function
(jqXHR, textStatus, errorThrown)
{
alert(
'Error adding / update data'
);
$(
'#btnSave'
).text(
'save'
);
//change button text
$(
'#btnSave'
).attr(
'disabled'
,false);
//set button enable
}
});
}
function
delete_person(id)
{
if
(confirm(
'Are you sure delete this data?'
))
{
// ajax delete data to database
$.ajax({
url :
"<?php echo site_url('person/ajax_delete')?>/"
+id,
type:
"POST"
,
dataType:
"JSON"
,
success:
function
(data)
{
//if success reload ajax table
$(
'#modal_form'
).modal(
'hide'
);
reload_table();
},
error:
function
(jqXHR, textStatus, errorThrown)
{
alert(
'Error deleting data'
);
}
});
}
}
</script>
<!-- Bootstrap modal -->
<div
class
=
"modal fade"
id=
"modal_form"
role=
"dialog"
>
<div
class
=
"modal-dialog"
>
<div
class
=
"modal-content"
>
<div
class
=
"modal-header"
>
<button type=
"button"
class
=
"close"
data-dismiss=
"modal"
aria-label=
"Close"
><span aria-hidden=
"true"
>×</span></button>
<h3
class
=
"modal-title"
>Person Form</h3>
</div>
<div
class
=
"modal-body form"
>
<form action=
"#"
id=
"form"
class
=
"form-horizontal"
>
<input type=
"hidden"
value=
""
name=
"id"
/>
<div
class
=
"form-body"
>
<div
class
=
"form-group"
>
<label
class
=
"control-label col-md-3"
>First Name</label>
<div
class
=
"col-md-9"
>
<input name=
"firstName"
placeholder=
"First Name"
class
=
"form-control"
type=
"text"
>
<span
class
=
"help-block"
></span>
</div>
</div>
<div
class
=
"form-group"
>
<label
class
=
"control-label col-md-3"
>Last Name</label>
<div
class
=
"col-md-9"
>
<input name=
"lastName"
placeholder=
"Last Name"
class
=
"form-control"
type=
"text"
>
<span
class
=
"help-block"
></span>
</div>
</div>
<div
class
=
"form-group"
>
<label
class
=
"control-label col-md-3"
>Gender</label>
<div
class
=
"col-md-9"
>
<select name=
"gender"
class
=
"form-control"
>
<option value=
""
>--Select Gender--</option>
<option value=
"male"
>Male</option>
<option value=
"female"
>Female</option>
</select>
<span
class
=
"help-block"
></span>
</div>
</div>
<div
class
=
"form-group"
>
<label
class
=
"control-label col-md-3"
>Address</label>
<div
class
=
"col-md-9"
>
<textarea name=
"address"
placeholder=
"Address"
class
=
"form-control"
></textarea>
<span
class
=
"help-block"
></span>
</div>
</div>
<div
class
=
"form-group"
>
<label
class
=
"control-label col-md-3"
>
Date
of Birth</label>
<div
class
=
"col-md-9"
>
<input name=
"dob"
placeholder=
"yyyy-mm-dd"
class
=
"form-control datepicker"
type=
"text"
>
<span
class
=
"help-block"
></span>
</div>
</div>
<div
class
=
"form-group"
id=
"photo-preview"
>
<label
class
=
"control-label col-md-3"
>Photo</label>
<div
class
=
"col-md-9"
>
(No photo)
<span
class
=
"help-block"
></span>
</div>
</div>
<div
class
=
"form-group"
>
<label
class
=
"control-label col-md-3"
id=
"label-photo"
>Upload Photo </label>
<div
class
=
"col-md-9"
>
<input name=
"photo"
type=
"file"
>
<span
class
=
"help-block"
></span>
</div>
</div>
</div>
</form>
</div>
<div
class
=
"modal-footer"
>
<button type=
"button"
id=
"btnSave"
onclick=
"save()"
class
=
"btn btn-primary"
>Save</button>
<button type=
"button"
class
=
"btn btn-danger"
data-dismiss=
"modal"
>Cancel</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!--
End
Bootstrap modal -->
</body>
</html>
Demo
Download source code :
Download
Semoga bermanfaat..!
Mohon koreksi jika ada kesalahan..!
0 Response to "(Codeigniter) Ajax CRUD menggunakan modals Bootstrap dan DataTables dengan Upload Gambar"
Posting Komentar