简体   繁体   English

如何在iOS中选择模糊事件以匹配桌面?

[英]How can I make select's blur event in iOS to match desktop?

I have a custom FullDate field that's comprised of a Month (Select), Day (Numeric TextBox), and Year (Numeric TextBox). 我有一个自定义FullDate字段,包括月(选择),日(数字文本框)和年(数字文本框)。

I have inline validations set up to run when the user blurs out of the field as a whole. 当用户模糊整个字段时,我设置了内联验证。 The problem is, on desktop, when you select something in a select box, you don't run inline validations until you tab out of the field or click on something else. 问题是,在桌面上,当您在选择框中选择某些内容时,在您跳出字段或单击其他内容之前,不会运行内联验证。 On iOS, however, blur seems to fire as soon as you select an option in the select box. 但是,在iOS上,只要在选择框中选择一个选项,模糊似乎就会激活。

Any good way to handle that? 有什么好方法可以处理吗?

http://jsfiddle.net/L5s3rq84/1/ http://jsfiddle.net/L5s3rq84/1/

<select name="colors" id="test">
    <option>RED</option>
    <option>GREEN</option>
    <option>YELLOW</option>
    <option>BLUE</option>
    <option>ORANGE</option>
</select>

<select name="colors" id="fake">
    <option>RED</option>
    <option>GREEN</option>
    <option>YELLOW</option>
    <option>BLUE</option>
    <option>ORANGE</option>
</select>

$("#test").on("blur", act);

function act() {
    alert("TESTING!");
}

This is because you don't get a blur event at all. 这是因为你根本没有得到模糊事件。 You have the following options: 您有以下选择:

to move to "change" (instead of "blur") event: http://jsfiddle.net/73bynhjq/1/ 移动到“改变”(而不是“模糊”)事件: http//jsfiddle.net/73bynhjq/1/

$("#test").on("change", act);

or you can do additional click event that that fires "blur" :) 或者您可以执行其他点击事件,触发“模糊”:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM