嘿,所有!有关用户显示和JavaScript的快速问题。我想要做的是关闭更新箭头gif,显示旋转的箭头,做更新,隐藏旋转的箭头,最后显示说这个项目现在设置的gif。通过三个循环循环 - 有些科室不改变
我的问题是旋转的箭头从不显示。我把睡眠放在那里,因为我认为更新发生得如此之快,以至于我没有看到它,但似乎并非如此。
任何帮助非常感谢。
function sleep(milliSeconds){
var startTime = new Date().getTime(); // get the current time
while (new Date().getTime() < startTime + milliSeconds); // hog cpu
}
function UpdateConfig(some_id) {
/* loop through all divs of class .changed_dropdown and if visible do something */
$(".changed_dropdown").each(function(index) {
if($(this).is(":visible")){
some_id = ($(this).data('some_id'));
/* turn off the div that shows this is in need of update (uparrow gif) */
$('#changed'+some_id).toggle(false);
/* turn on the div that displays the arrows going around in a circle (roundarrow gif) */
$('#updating'+some_id).toggle(true);
/* pause to allow the divs to change */
sleep(500);
var new_config = $("#" + some_id).val();
$.post("change_config.php?some_id="+some_id+"&config="+new_config);
/* turn off the div that displays the arrows going around in a circle (roundarrow gif) */
$('#updating'+some_id).toggle(false);
/* turn on the gif that indicates this is the current setting */
$('#unchanged'+some_id).toggle(true);
}
});
}
这确实得到了旋转箭头来显示,但现在处理程序中的切换不起作用。 – 2011-04-21 18:10:34
好的,我想我明白了为什么发生这种情况 - 我会更新答案。 – Pointy 2011-04-21 18:16:25
对于some_id你是对的,我还没有机会清理它。感谢您的提醒。尽管第二批切换仍然没有触发。 – 2011-04-21 18:56:02