Commit 8d3c5cc8 by Phạm Văn Đoan

tối ưu ajax/cms_track/list_track_view.php

parent 0a5c6670
......@@ -32,6 +32,8 @@ class CmsTrack extends CI_Controller
{
$data = array();
$fByName = $this->input->post('fByName');
$fBySinger = $this->input->post('fBySinger');
$fByComposer = $this->input->post('fByComposer');
$pageId = $this->input->post('pageId');
//
$pageId = ($pageId == 0) ? 1 : $pageId;
......
......@@ -6,6 +6,8 @@
<th style="text-align: center">Ảnh</th>
<th style="text-align: center">#ID</th>
<th style="text-align: center">Tên bài hát</th>
<th style="text-align: center">Ca sĩ</th>
<th style="text-align: center">Sáng tác</th>
<th style="text-align: center">Xử lý</th>
</tr>
</thead>
......@@ -18,6 +20,8 @@
</td>
<td style="text-align: center">#<?php echo $data['id']; ?></td>
<td style="text-align: left"><?php echo $data['title']; ?></td>
<td style="text-align: left"><?php echo $data['singer_list']; ?></td>
<td style="text-align: left"><?php echo $data['composer_list']; ?></td>
<td style="text-align: center">
<a href="<?php echo base_url().'backend/cmsTrack/showTrack/'.$data['id']; ?>" title="Xem chi tiết">
<i class="ace-icon fa fa-eye bigger-130"></i>
......
......@@ -23,6 +23,7 @@
<div class="row">
<?php echo form_open(base_url().'backend/cmsTrack/listTrackAjax'); ?>
<!-- Tìm kiếm theo tên bài hát -->
<div class="col-lg-3">
<input
class="form-control" type="text"
......@@ -30,6 +31,23 @@
id="input-name"
placeholder="Nhập tên bài hát..."/>
</div>
<!-- Lọc theo thông tin ca sĩ -->
<div class="col-lg-3">
<select class="form-control" name="fBySinger" id="fBySinger">
<option value="-1">Thông tin ca sĩ</option>
<option value="1">Đã cập nhật</option>
<option value="2">Chưa cập nhật</option>
</select>
</div>
<!-- Lọc theo thông tin nhạc sĩ -->
<div class="col-lg-3">
<select class="form-control" name="fByComposer" id="fByComposer">
<option value="-1">Thông tin nhạc sĩ</option>
<option value="1">Đã cập nhật</option>
<option value="2">Chưa cập nhật</option>
</select>
</div>
<div class="col-lg-3"></div>
<div class="col-lg-1">
<button class="btn btn-sm btn-default" id="delete-filter">Xóa bộ lọc</button>
</div>
......@@ -62,94 +80,62 @@
loadDataByAjaxFromInput(url);
}, 250);
});
loadDataByAjaxFromSelectBox('fBySinger', url);
loadDataByAjaxFromSelectBox('fByComposer', url);
// Xóa bộ lọc
$('#delete-filter').click(function(){
$("#input-name").val('');
changePagination('0');
$("#fBySinger").val('-1');
$("#fByComposer").val('-1');
changePagination('0', url);
return false;
});
changePagination('0');
changePagination('0', url);
});
//Ham chung cho cac input
function loadDataByAjaxFromInput(url){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
callAjax(0, url);
}
//Ham chung cho cac SelectBox
function loadDataByAjaxFromSelectBox(id, url){
$('#'+id).change(function(){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
callAjax(0, url);
});
}
function loadDataByAjaxDateRange(dtFrom, dtTo, url){
$('#data-loading').show();
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var fByName = $("#input-name").val();
// ajax
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName
},
dataType: "text",
cache: false,
success: function(data){
$('#div-response').html(data);
$('#data-loading').hide();
}
});
callAjax(pageId, url);
}
function changePagination(pageId) {
function changePagination(pageId, url) {
$('#data-loading').show();
callAjax(pageId, url);
}
function callAjax(pageId, url) {
var csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
var url = '<?php echo base_url()."backend/cmsTrack/listTrackAjax"; ?>';
var fByName = $("#input-name").val();
//Ajax ve bieu do\
var fBySinger = $("#fBySinger").val();
var fByComposer = $("#fByComposer").val();
//Ajax
$.ajax({
type: "POST",
url: url,
data: {
csrf_name: csrf_value,
fByName: fByName,
fBySinger: fBySinger,
fByComposer: fByComposer,
pageId: pageId
},
dataType: "text",
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment