1
我已经写了一个JavaScript代码来更新yii GridView表,每隔10秒后向用户显示正常工作。jQuery Yii更新数据表,仅当显示Tab时
timedRefresh($page_refresh_time);
function timedRefresh(timeoutPeriod) {
setTimeout(function(){refreshGrid()}, timeoutPeriod);
}
function refreshGrid() {
$.fn.yiiGridView.update(\"group-grid\");
timedRefresh($page_refresh_time);
}
但现在我想改变我的代码时,将显示选项卡和时间表的作息不刷新该表只刷新。所以我将我的代码更改为:
timedRefresh($page_refresh_time);
function timedRefresh(timeoutPeriod) {
setTimeout(function(){refreshGrid()}, timeoutPeriod);
}
function refreshGrid() {
$('a[href=\"#dash2\"]').on('shown', function(e) {
$.fn.yiiGridView.update(\"group-grid\");
timedRefresh($page_refresh_time);
});
}
其中dash2
是选项卡的ID。现在问题在于,在更新我的代码后,每10秒刷新一次表就已经占上风。任何人都可以请指导我在上面的JavaScript代码中犯了一个错误吗?
此外,我希望表格停止刷新一旦选项卡关闭。我怎样才能做到这一点?
感谢萨穆埃尔的解决方案,用于更新我的有关知识“表示”因为我是新到jQuery,JavaScript的东西。 – prattom