焦点过滤选择页面加载 [英] focus filtering select on page load
问题描述
为什么下面的代码不关注过滤选择?
<!DOCTYPE HTML>
< html>
< head>
< script type =text / javascriptsrc =http://yandex.st/dojo/1.6.0/dojo/dojo.xd.jsdjConfig =parseOnLoad:true>< /脚本>
< style type =text / css>
@importhttp://yandex.st/dojo/1.6.0/dijit/themes/claro/claro.css;
< / style>
< script type =text / javascript>
<! -
dojo.require(dijit.form.FilteringSelect);
dojo.addOnLoad(function(){
dijit.byId('dept')。focus();
});
- >
< / script>
< / head>
< body class =claro>
< option value =>< / option>
< option value =test> test< / option>
< option value =test1> test1< / option>
< / select>
< / body>
< / html>
我试过用ie7和firefox 3/4 - 它可以工作。
但它在ie8中失败:-(
这可能是一个dojo错误 - 或者我做错了什么?
何时dojo.addOnLoad()在DOM准备好之后触发? ,或所有的小部件已经适当地初始化了?
关于
gerhard
这是非常有趣的错误..我做了一些小的研究并找到了解决方案,也许它看起来像一个肮脏的黑客,但它仍然可以帮助你。
你可以只需添加超时时间:
$ p $ dojo.addOnLoad(function(){
setTimeout(function(){dijit.byId 'dept')。focus()},400);
});
不是
why does the following code don't focus the filteringselect?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://yandex.st/dojo/1.6.0/dojo/dojo.xd.js" djConfig="parseOnLoad: true"></script>
<style type="text/css">
@import "http://yandex.st/dojo/1.6.0/dijit/themes/claro/claro.css";
</style>
<script type="text/javascript">
<!--
dojo.require("dijit.form.FilteringSelect");
dojo.addOnLoad(function(){
dijit.byId('dept').focus();
});
-->
</script>
</head>
<body class="claro">
<select name="dept" id="dept" dojoType="dijit.form.FilteringSelect" >
<option value=""></option>
<option value="test">test</option>
<option value="test1">test1</option>
</select>
</body>
</html>
I tried it with ie7 and firefox 3/4 - it works.
but it fails in ie8 :-(
may this be a dojo bug - or am I doing something wrong?
when does dojo.addOnLoad() fire? after the DOM is ready, or after all widgets have properly been initalized?
regards
gerhard
it's very intresting bug.. i have made small research and found solution. maybe it looks like a "dirty hack", but still it can help you.
you can simply add timeout:
dojo.addOnLoad(function () {
setTimeout(function () { dijit.byId('dept').focus() }, 400);
});
Not noticeable by a user but it gives IE a moment to breathe.
这篇关于焦点过滤选择页面加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!