admin管理员组文章数量:1297062
I am trying to reload alerts
container after a pjax request.
What I am aiming for is a code that will reload the container after any pjax request has been made, so I don't have to individually call it every time.
I have the following code:
$(document).on('pjax:plete', function(event) {
$.pjax.reload({container:"#alerts"});
});
However, this sends the whole page into a never ending loop.
Is there a way to make this work or should I not use pjax for this particular problem?
Thank you very much.
Update The following code works, but I feel it is not the perfect solution:
var time = Date.now();
$(document).on(\'pjax:plete\' , 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});
}
});
I am trying to reload alerts
container after a pjax request.
What I am aiming for is a code that will reload the container after any pjax request has been made, so I don't have to individually call it every time.
I have the following code:
$(document).on('pjax:plete', function(event) {
$.pjax.reload({container:"#alerts"});
});
However, this sends the whole page into a never ending loop.
Is there a way to make this work or should I not use pjax for this particular problem?
Thank you very much.
Update The following code works, but I feel it is not the perfect solution:
var time = Date.now();
$(document).on(\'pjax:plete\' , 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});
}
});
Share
edited Oct 26, 2015 at 15:51
Chris Illusion
asked Oct 26, 2015 at 12:47
Chris IllusionChris Illusion
2872 gold badges6 silver badges18 bronze badges
2
- See this answer too stackoverflow./questions/27777512/… you'll need to set the timeout as well else it won't work. – Coz Commented Oct 26, 2015 at 14:07
- I've updated the question. Quite the opposite worked. – Chris Illusion Commented Oct 26, 2015 at 16:01
2 Answers
Reset to default 5try pjax on particular id of Pjax Widget as:-
$this->registerJs('
jQuery(document).on("pjax:success", "#brand-form", function(event){
$.pjax.reload({container:"#alerts",timeout:2e3})
}
);
');
Your problem may be taking a URL pjax container to add the option location
to taking containers. if you page many one pjax to need to add pjax id
and location
本文标签: javascriptPjax reload in pjaxcompleteStack Overflow
版权声明:本文标题:javascript - Pjax reload in pjax:complete - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741647223a2390256.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论