问题的标题表达了我认为是我的具体案例背后的最终问题.
我的情况:在一个点击处理程序中,我想在繁忙的函数开始之前使图像可见(一个'加载'动画).然后我想在函数完成后再次使它不可见.而不是我所期望的,我意识到图像永远不会变得可见.我想这是由于浏览器等待处理程序结束,然后才能进行任何重绘(我确信有很好的性能原因).
代码(也在这个小提琴:http://jsfiddle.net/JLmh4/2/)
HTML:
<img id="kitty" src="http://placekitten.com/50/50" style="display:none">
<div><a href="#" id="enlace">click to see the cat</a> </div>
Run Code Online (Sandbox Code Playgroud)
JS:
$(document).ready(function(){
$('#enlace').click(function(){
var kitty = $('#kitty');
kitty.css('display','block');
// see: http://unixpapa.com/js/sleep.html
function sleepStupidly(usec)
{
var endtime= new Date().getTime() + usec;
while (new Date().getTime() < endtime)
;
}
// simulates bussy proccess, calling some function...
sleepStupidly(4000);
// when this triggers the img style do refresh!
// but not before
alert('now you do see it');
kitty.css('display','none');
});
});
Run Code Online (Sandbox Code Playgroud)
我alert在sleepStupidly …
我想知道天气可能以及如何为列表视图配置过滤器,如下所示,Symfony 2中的SonataAdminBundle
假设我有实体Order,指向实体User,指向实体Company.我想配置过滤器既可以由用户过滤,也可以按公司(用户公司)进行过滤.第一个是直接过滤.第二个是我试图澄清的内容.
在OrderAdmin类中,我将覆盖configureDatagridFilters:
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('created_at')
//... some other filters on Order fields, as usual
// the filter on User, provided 'user', no ploblem
->add('user')
// and the filter by Company
->add('user.company') // this doesn't work, of course
;
}
Run Code Online (Sandbox Code Playgroud)
公司过滤器的语法是由sonta docs提供的:http://sonata-project.org/bundles/doctrine-orm-admin/2-0/doc/reference/filter_field_definition.html
不是为了我想要的东西,但找不到在哪里看.
希望有人对此有所了解.
谢谢