Simplemodal - 如何在 onShow 函数中将焦点设置在元素上
我以为事情会很简单。只是
...
onShow:function(dialog){
dialog.data.find("input#myInput").focus();
}
...
,但似乎不起作用。
与SimpleModal的focus()函数有冲突吗?
我注意到,如果我在 onShow 函数中放置一个alert(),它会在模态可见之前弹出。有没有办法在显示模式后调用函数(即 focus()),但无需用户输入(无需用户触发某种事件)?
另外,当我尝试将 simplemodal
focus:true
与dialog.data一起使用时=
'<div class="myModal login">'+
'<div class="modalTitle">Title</div>'+
'<div class="modalContent">'+
'<label for="username">Login: </label>'+
'<input id="username" />'+
'<br />'+
'<label for="password">Pass: </label>'+
'<input id="password" type="password" />'+
'<br />'+
'<div class="confirmButton no simplemodal-close">Cancel</div>'+
'<div class="confirmButton yes">Login</div>'+
'</div>'+
'</div>'
焦点位于包装器上(至少我这么认为)并且用户必须按选项卡才能到达第一个输入元素。
任何帮助都会很棒,
格雷格。
I thought it is going to be simple. Just
...
onShow:function(dialog){
dialog.data.find("input#myInput").focus();
}
...
but it doesn't seem to work.
Is there a conflict with SimpleModal's focus() function?
I noticed that if i put an alert() inside onShow function it pops before modal is visible. Is there a way to call function (ie. focus()) after displaying modal, but without user input (without user triggering some kind of event)?
Also when i tried to use simplemodal's
focus:true
with dialog.data =
'<div class="myModal login">'+
'<div class="modalTitle">Title</div>'+
'<div class="modalContent">'+
'<label for="username">Login: </label>'+
'<input id="username" />'+
'<br />'+
'<label for="password">Pass: </label>'+
'<input id="password" type="password" />'+
'<br />'+
'<div class="confirmButton no simplemodal-close">Cancel</div>'+
'<div class="confirmButton yes">Login</div>'+
'</div>'+
'</div>'
focus is on wrapper (at least i think so) and user has to press tab to get to first input element.
Any help would be great,
Greg.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
希望这有帮助。干杯
Try this:
Hope this helps. Cheers