简体   繁体   English

在Django中显示加载微调器的最佳方法?

[英]Best way to display a loading spinner in Django?

What is the best way to display a loading spinner in Django during a relatively lengthy server-side processing task? 在相对冗长的服务器端处理任务期间,在Django中显示加载微调器的最佳方法是什么? Is this something that JS/jQuery should handle? 这是JS / jQuery应该处理的吗?

If so, how do I get the button click that starts the server-side processing to initiate the spinner? 如果是这样,我如何获得按钮单击以启动服务器端处理以启动微调器?

Django novice here, so I appreciate any input. 这里是Django新手,因此感谢您的投入。 Thanks! 谢谢!

There are many ways of doing this, I'm going to suggest the simplest: 有很多方法可以做到这一点,我将建议最简单的方法:

Use an animated gif 使用动画gif

yes. 是。 I know, you're probably thinking, "animated gifs are tacky!" 我知道,您可能在想,“动画gif太俗气了!”

to which I reply: "only if they're ugly." 我回答:“只有它们很丑。”

Make a simple loading spinner animation as a gif, and add it to the display list when you want it shown. 制作一个简单的加载微调器动画作为gif,并在需要显示时将其添加到显示列表中。 When the process is over, remove it from the display list. 该过程结束后,将其从显示列表中删除。

It's about the only good use of an animated gif I've ever come up with. 这是我想出的动画gif的唯一好用法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM