“忙碌等待”的最佳方式是动画是“位置可配置的”在jquery中? (即,显示操作在哪里)
我打算有一个繁忙的等待旋转器,如本文所示:如何显示在 jQuery 中加载微调器? - 因为它是最干净且最容易实现的:
$('#loadingDiv')
.hide() // hide it initially
.ajaxStart(function() {
$(this).show();
})
.ajaxStop(function() {
$(this).hide();
})
;
并将其与 http://www.ajaxload.info/
我的页面中有多个“视图”,即,我的页面的不同部分可以使用相应的 ajax 调用进行更新/修改。
我想将这个#loadingDiv
“定位”到靠近“操作”的位置。我应该怎样去做呢?
想到的很少有事情:
- 在整个地方有多个 div 并将它们隐藏并根据相应的操作在每个元素中显示它们 - 似乎天真且浪费
- 有一个空的
来“保留”
#loadingDiv
- 当该范围内发生某些事情时显示它。但我不知道该怎么做... - 还有别的吗?
基本上如何最好地处理位置繁忙等待/信号而不是单一的全局信号?或者是首选单一全局选项,即,要在每个活动的页面顶部/中心隐藏显示“固定”div?
只是想知道你们大多数人使用/喜欢哪个选项来解决类似的问题,以及您建议我如何去做......
I intend to have a busy waiting spinner as per shown in this post: How to show loading spinner in jQuery? - since it's the cleanest and easiest to implement:
$('#loadingDiv')
.hide() // hide it initially
.ajaxStart(function() {
$(this).show();
})
.ajaxStop(function() {
$(this).hide();
})
;
and couple it up with the animations from http://www.ajaxload.info/
I have multiple "views" in my page i.e., different parts of my page can be updated/modified with the corresponding ajax calls.
I'd like to "position" this #loadingDiv
close to where the 'action is' so to speak. How should I go about doing it?
Few things that come to mind:
- Have multiple divs all over the place and have them hidden and show them per element as per the corresponding action - seems naive and wasteful
- Have an empty
<span></span>
to 'hold' the#loadingDiv
- show it when something happens in that span. I don't know how to do this though... - Something else??
Basically how best to approach positional busy waiting/signalling rather than have a single global one? Or is the single-global option preferred i.e., To have a "fixed" div, hidden show up on the top/center of the page for every activity?
Just want to know which option most of you have used/preferred to tackle something like that and how do you suggest I go about it...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一些事情需要考虑:
如果用户在请求加载时与页面的其他部分交互,是否会导致问题?
这些操作是否很小,与应用程序的其余部分无关?
如果请求很重要,但您想让用户乱搞,并且 GUI 很复杂
本地更新,非阻塞方式
There are some things to consider:
Can the user cause problems if he interacts with other parts of the page while the request is loading?
Are the actions tiny and small, irrelevant to the rest of the application?
If the request is significant but you want to let the user to mess around, and the GUI is complex
Local updates, the non blocking way