我得到了带有选项的过滤器,如果我指定了选项“dead”,则使用 jQuery,它仅显示状态为:dead; 的行。但是当我向下滚动并触发无限ajax滚动时,数据库中的新数据不仅显示状态为:dead的行。可以保存过滤器以用于带有ajax滚动的新页面
我的代码
<script type="text/javascript">
$(document).ready(function() {
// Infinite Ajax Scroll configuration
jQuery.ias({
container : '.wrap', // main container where data goes to append
item: '.item', // single items
pagination: '.nav', // page navigation
next: '.nav a', // next page selector
loader: '<img src="css/ajax-loader.gif"/>', // loading gif
triggerPageThreshold: 5 // show load more if scroll more than this
});
});
</script>
<script>
function replaceQueryParam(param, newval, search) {
var regex = new RegExp("([?;&])" + param + "[^&;]*[;&]?");
var query = search.replace(regex, "$1").replace(/&$/, '');
return (query.length > 2 ? query + "&" : "?") + (newval ? param + "=" + newval : '');
}
$(window).load(function() {
$('#select_box').change(function() {
if($(this).val() == 'notresolved') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:contains('Разрешен')").hide();
}
if($(this).val() == 'new') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Нов'))").hide();
}
if($(this).val() == 'opened') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Отворен'))").hide();
}
if($(this).val() == 'resolved') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Разрешен'))").hide();
}
if($(this).val() == 'dead') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Dead'))").hide();
}
if($(this).val() == 'all') {
$( '#table-tbody #table-tr').show();
}
});
$('#queue_box').change(function() {
if($(this).val() == 'mitev') {
window.location = 'test1.php' + replaceQueryParam('quid', 5, window.location.search)
}
if($(this).val() == 'all') {
window.location = 'test1.php' + replaceQueryParam('quid', -1, window.location.search)
}
if($(this).val() == 'office') {
window.location = 'test1.php' + replaceQueryParam('quid', 6, window.location.search)
}
if($(this).val() == 'support_c') {
window.location = 'test1.php' + replaceQueryParam('quid', 2, window.location.search)
}
if($(this).val() == 'clients') {
window.location = 'test1.php' + replaceQueryParam('quid', 8, window.location.search)
}
if($(this).val() == 'mtel') {
window.location = 'test1.php' + replaceQueryParam('quid', 10, window.location.search)
}
if($(this).val() == 'ro-ni') {
window.location = 'test1.php' + replaceQueryParam('quid', 11, window.location.search)
}
});
});
$(function() {
if (localStorage.getItem('queue_box')) {
$("#queue_box option").eq(localStorage.getItem('queue_box')).prop('selected', true);
}
$("#queue_box").on('change', function() {
localStorage.setItem('queue_box', $('option:selected', this).index());
});
});
</script>
</head>
<body>
<?php
session_start();
if(!isset($_SESSION['customer_id']) && empty($_SESSION['customer_id'])) {
header("Location: login.php");
}
?>
<div id="wrapper">
<div id="header">
<h1><a href="index.php" style="text-decoration:none;color:#039;">Ticket system</a></h1>
<div style="text-align:left;vertical-align:bottom;">
<img src="images/save.gif" /><a href="addticket.php" style="text-decoration:none;color:#039;">New Ticket</a>
</div>
</div>
<div id="filter">
<!--Нови: <input type="checkbox" id="check_box1">
Разрешени: <input type="checkbox" id="check_box2">
Отворени: <input type="checkbox" id="check_box3">
Неразрешени: <input type="checkbox" id="check_box4"> -->
Queue: <select id="queue_box" style="height:35px;">
<option value="all" selected="selected">- всички -</option>
<option value="mitev"> Стойчо Митев</option>
<option value="office"> Офис & инфо</option>
<option value="support_c"> Поддръжка Клиенти</option>
<option value="clients"> Клиенти</option>
<option value="mtel"> Огледи Мтел</option>
<option value="ro-ni"> Поддръжка Ро-Ни</option>
</select><br>
Статус: <select id="select_box" style="height:35px;">
<option value="all">- всички -</option>
<option value="new">нов</option>
<option value="opened">отворени</option>
<option value="resolved">разрешени</option>
<option value="dead">dead</option>
<option value="notresolved">неразрешени</option>
</select>
</div>
i was thinking of something like this
`ias.on('load', function(event) {
if($("#select_box").val() == 'notresolved') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:contains('Разрешен')").hide();
}
if($("#select_box").val() == 'new') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Нов'))").hide();
}
if($("#select_box").val() == 'opened') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Отворен'))").hide();
}
if($("#select_box").val() == 'resolved') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Разрешен'))").hide();
}
if($("#select_box").val() == 'dead') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Dead'))").hide();
}
if($("#select_box").val() == 'all') {
$( '#table-tbody #table-tr').show();
}
});`
我正在考虑这样的事情,你会说什么
请您参考如下方法:
我找不到任何允许 ias() 使用附加参数的东西,所以我只能建议(这可能不是现在最好的解决方案)不断地(比如在触发某些事件)请像现在一样使用 $('#select_box').change(function()
。如果我在 ias()
中遗漏了某些内容,请通知我.
示例:
$(document).ready(function() {
// Infinite Ajax Scroll configuration
jQuery.ias({
container : '.wrap', // main container where data goes to append
item: '.item', // single items
pagination: '.nav', // page navigation
next: '.nav a', // next page selector
loader: '<img src="css/ajax-loader.gif"/>', // loading gif
triggerPageThreshold: 5, // show load more if scroll more than this
onLoadItems: apply_changes()
// OR:
onLoadItems: function(items) {
// Paste everything that function apply_changes() has.
}
}
});
function apply_changes()
{
if($('#select_box').val() == 'notresolved') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:contains('Разрешен')").hide();
}
if($('#select_box').val() == 'new') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Нов'))").hide();
}
if($('#select_box').val() == 'opened') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Отворен'))").hide();
}
if($('#select_box').val() == 'resolved') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Разрешен'))").hide();
}
if($('#select_box').val() == 'dead') {
$( '#table-tbody #table-tr').show();
$( "#table-tbody #table-tr:not(:contains('Dead'))").hide();
}
if($('#select_box').val() == 'all') {
$( '#table-tbody #table-tr').show();
}
}