在Mobile Safari中,在设置延迟时间后,我无法将注意力集中在文本字段上.我附上一些展示问题的示例代码.如果单击该按钮,则触发.focus(),一切都按预期工作.如果你把焦点放在回调上,比如setTimeout函数,那么它只能在移动safari中失败.在所有其他浏览器中,有一个延迟,然后焦点发生.
令人困惑的是,即使在移动游猎中,也会触发"focusin"事件.这个(和SO中的〜类似〜评论)让我觉得它是一个移动的safari bug.任何指导都将被接受.
我已经在模拟器和iPhone 3GS/4 iOS4上进行了测试.
示例HTML:
<!DOCTYPE html>
<html lang='en'>
<head>
<title>Autofocus tests</title>
<meta content='width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0' name='viewport'>
<meta content='yes' name='apple-mobile-web-app-capable'>
</head>
<body>
<h1>
Show keyboard without user focus and select text:
</h1>
<p>
<button id='focus-test-button'>
Should focus on input when you click me after .5 second
</button>
<input id='focus-test-input' type='number' value='20'>
</p>
<script type="text/javascript">
//<![CDATA[
var button = document.getElementById('focus-test-button');
var input = document.getElementById('focus-test-input');
input.addEventListener('focusin', function(event) {
console.log('focus');
console.log(event);
});
button.addEventListener('click', function() {
// *** If …
Run Code Online (Sandbox Code Playgroud) 我有一个iPhone应用程序请求API,它使用嵌套的param结构传入用户名和密码登录.
在我的Rails控制器中,我通常使用以下方法成功检索此信息:
username = param[:session][:username]
Run Code Online (Sandbox Code Playgroud)
我想使用cURL从shell测试我的API.但我无法弄清楚如何提供嵌套参数?下面的代码不起作用......我尝试了多种变体.但似乎无法弄明白?
curl -d '{"session":{"username":"test","password":"password"}}' http://testurl/remote/v1/sessions
Run Code Online (Sandbox Code Playgroud)
任何帮助,非常感谢!