Chr*_*ion 1 javascript pjax yii2
我正在尝试alerts
在 pjax 请求后重新加载容器。我的目标是在发出任何 pjax 请求后重新加载容器的代码,因此我不必每次都单独调用它。
我有以下代码:
$(document).on('pjax:complete', function(event) {
$.pjax.reload({container:"#alerts"});
});
Run Code Online (Sandbox Code Playgroud)
然而,这会使整个页面陷入永无休止的循环。
有没有办法让这个工作或者我不应该使用 pjax 来解决这个特定的问题?
非常感谢。
更新 以下代码有效,但我觉得这不是完美的解决方案:
var time = Date.now();
$(document).on(\'pjax:complete\' , function(event) {
if(time <= Date.now()){ //Check if there has been a recent reload
time = Date.now() + 1000;
console.log(time);
App.restartGlobalFunction();
$.pjax.reload({container:"#alerts", async:false});
}
});
Run Code Online (Sandbox Code Playgroud)
在 Pjax Widget 的特定 id 上尝试 pjax:-
$this->registerJs('
jQuery(document).on("pjax:success", "#brand-form", function(event){
$.pjax.reload({container:"#alerts",timeout:2e3})
}
);
');
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
20587 次 |
最近记录: |