【发布时间】:2017-04-06 02:09:03
【问题描述】:
我有一个 DetailView ,我在其中呈现有关我的 models.Auction 对象的详细信息,包括 expires 参数(使用 jquery.countdown 倒计时时间和完成后的触发事件)。
这是倒计时和完成事件的代码:
<script>
$('#clock').countdown('{{ auction.get_time_left }}', function(event) {
$(this).html(event.strftime('%D {% trans "day/days" %} %H:%M:%S'));
}).on('finish.countdown', function(){
setTimeout(function(){ location.reload()}, 1500);
});
</script>
在视图中,我检查是否:
if datetime.now() >= context['auction'].expires:,我渲染了一个不同的模板;
但由于某些原因,当它执行location.reload() 时,它不会检查该条件(跳过它)并呈现相同的模板(时间已过期)。
附言我也尝试在终端中打印一些东西(但它也跳过了打印)
【问题讨论】:
标签: jquery django django-templates django-views jquery-countdown