问题描述
我正在创建一个Cordova PhoneGap应用,并且在输入字段有问题。
I'm creating a Cordova PhoneGap app and have trouble with the input fields.
我使用iScroll滚动和刷新。
I'm using iScroll for scroll and refresh.
突然我的输入字段没有响应。因此,用户在启动应用程序时无法登录。
Suddenly my input fields aren't responding. So users can't even login when they start the app.
我使用标准字段,我无法给输入字段焦点。甚至没有设置[input] .focus()的包装器。
I use standard fields and i can't give the input fields focus. Not even with a wrapper where I set "[input].focus()".
html代码是
<input class="newinput" onclick="this.focus();" type="email" id="email" name="email" value="" autocorrect="off" autocapitalize="off" required="" placeholder="Enter E-mail address">
CSS
.newinput {
width: 100%;
border: none;
padding: 0;
margin: 3px 0px 1px 0px;
background: white;
font-size: 16px;
color: #43ACDB;
z-index: 40;
}
其他样式(可通过Chrome开发者控制台找到)
Other style is (found with chrome developer console)
-webkit-writing-mode: horizontal-tb;
font: -webkit-small-control;
letter-spacing: normal;
word-spacing: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
display: inline-block;
text-align: start;
-webkit-tap-highlight-color: rgba(0,0,0,0);
-webkit-appearance: textfield;
-webkit-rtl-ordering: logical;
-webkit-user-select: text; // tried without this line too
cursor: auto;
输入字段之前已经工作,但突然不是一个可以获得焦点。不幸的是,我不会当他们停止工作,因为我有自动登录,所以我不使用输入字段大部分的应用程序功能。
The input fields have worked before but suddenly not a single one can get focus. Unfortunately, I don't when they stopped working cause I have auto-login so I don't use the input fields for most of the apps functionality.
所有js和css代码,并没有以-webkit-user开头的单行(除了调试)
I have checked all js and css code and haven't got a single line starting with "-webkit-user" (except for debugging)
如果我只是去index.html在我的Mac上的浏览器上,但android模拟器和浏览器上的iphone,android和ipad有这个错误
The code works fine if i just go to the index.html on a browser on my mac but android simulator and browser on iphone, android and ipad has this error
我还能做什么,让输入再工作?
What else can I do to get the input working again?
推荐答案
Ok找到答案。奇怪的是它自2010年以来一直在使用的iScroll错误。
Ok found the answer. Strangely enough its a iScroll bug that has been around since 2010.
使用以下设置:useTransform和onBeforeScrollStart。例如。
Use the following settings: useTransform and onBeforeScrollStart. E.g.
myScroll = new iScroll(
'wrapper', /** Change this to match your container ID **/
{
useTransform: true,
onBeforeScrollStart: function (e) {
var target = e.target;
while (target.nodeType != 1) {
target = target.parentNode;
}
if (target.tagName != 'SELECT' && target.tagName != 'INPUT'
&& target.tagName != 'TEXTAREA'
) {
e.preventDefault();
}
}
/** Add Any Additional Settings here **/
}
);
这篇关于输入不工作在phonegap应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!