我有 pjax:beforeReplace 的以下事件监听器来检查来自服务器的内容,如果满足条件,则不显示任何内容和
$(document).on("pjax:beforeReplace", function(e, contents) {
var $contentBeforePut = $(contents);
if(conditionHere) {
// here I want to prevent put html content, I tried with:
location.reload(true);
}
}
但不起作用,意味着放置了html内容,可见,然后重新加载页面。
$(document).on("pjax:end", function () {
// the code is executed even I put location.reload in beforeReplace event
});
我想在用pjax放入内容之前重新加载页面,怎么做?
答案 0 :(得分:0)
尝试
$(document).on("pjax:beforeReplace", function(e, contents) {
var $contentBeforePut = $(contents);
if(conditionHere) {
// here I want to prevent put html content, I tried with:
return false;
}
}
的参考资料