0

我将 Mobiscroll 称为如下:

$(joInputField).scroller({ 
    width:      60,  
    wheels:         wheels,     // wheels variable has been defined above
    headerText:     false,   // false for production!
    onSelect:       function(){  // event fired by BOTH set and cancel
        var stDate = '';
        var rawDate = $(joInputField).scroller('getValue');  
        // a bunch more code

Mobiscroll 的这种设置在 Firefox 17 和 IE9 中都可以正常工作。但是,它在 Chrome 23 中完全失败了。在 Chrome 中,当我单击输入字段以弹出 Mobiscroller 时,我什至会刷新页面。

点击事件按应有的方式附加,所以我认为这不是我的 HTML 页面中让 Chrome 感到不安的东西。此外,我在控制台中没有收到任何错误。

我刚刚将 Mobiscroll 从 1.5 升级到 2.3.1 这没有任何区别。在 Chrome 中仍然失败,在 FF 和 IE 中就像一个魅力。

有人有预感吗?

4

1 回答 1

1

好吧,终于有时间想办法了。

这是我的输入元素的配置方式:

<input id="mobiScroll" class="mobiscroll scroller" type="image" readonly="" value="5 07 05 19 5 5" name="mobiDick" src="<?php echo $options['assetsBase'] ?>/img/calendar-icon-40px2.png">

事实证明,在这种配置中,图像覆盖在输入元素上,Chrome 不会触发焦点事件。Mobiscroll 依赖于那个焦点事件。

最简单的解决方案(即最耗时)是这种变通方法,即单击输入元素会在所述元素上引发焦点事件,进而启动 Mobiscroll。

 // work around a Chrome quirk where focus event is not raised on input element:
joInputField.click(function() {
        joInputField.trigger('focus');                      
});

希望这可以帮助某人,在路上的某个地方......

于 2013-03-13T14:43:54.670 回答