使用 Mobile Safari“表单助手”在选择元素上未触发更改事件
我有动态选择下拉菜单。例如,如果您选择特定月份,第二个选择元素将填充该月的天数。
这按预期工作,但是当用户使用 iPhone 并使用 Mobile Safari 的“表单助手”中内置的“下一步”按钮时,change
事件(使用 jQuery)似乎不会触发,并且第二个选择不会更新。
$('.month').change(function() {
// update "days" select element
});
仅供参考,我也在使用 jQuery mobile
I have dynamic select drop-down menus. For example, if you select a specific month, the 2nd select element will populate with number of days in that month.
This works as intended, however when the user is on an iPhone and uses the "Next" button built into Mobile Safari's "form assistant", the change
event (using jQuery) doesn't appear to fire and the 2nd select does not update.
$('.month').change(function() {
// update "days" select element
});
FYI I'm also using jQuery mobile
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以绑定一些其他事件,例如
blur
(不过不知道 Blur 是否会在 iPhone 上触发)或者您尝试过:
You could also bind some additional events like
blur
( don't know if blur does fire on iphone though)or have you tried:
我能找到的最好的解决方法是基于这篇文章...
在 Mobile Safari 下拉列表项选择框中使用“下一步”时,select/dropdown 的 onchange() JS 事件的奇怪行为
使用插件(来自上面的链接),一旦使用 Mobile Safari 的“表单助手”选择了一个选项,我就必须强制选择菜单
模糊
。然而,我注意到,当强力测试这些菜单时,在几次来回选择后会触发额外的模糊事件。额外的
焦点
似乎可以解决这个问题。通过单独的
change
函数,我动态更新第二个选择菜单。*迄今为止仅在 Mobile Safari / iOS 5.0.1 上进行了测试。
The best work-around I could find was based on this post...
Strange behavior of select/dropdown's onchange() JS event when using 'Next' on Mobile Safari Dropdown list item select box
Using the plugin (from the link above), I had to force the select menu to
blur
as soon as an option was chosen with Mobile Safari's "form assistant".I noticed however when brute force testing these menus an extra
blur
event would fire after a few back-and-forth selections. An extrafocus
seemed to fix that.With a separate
change
function I am updating the second select menu dynamically.*Only tested on Mobile Safari / iOS 5.0.1 thus far.