【问题标题】:jQuery UI date picker makes problems with mobile devicesjQuery UI 日期选择器使移动设备出现问题
【发布时间】:2014-08-07 12:23:17
【问题描述】:

我们正在使用this jQuery UI date picker wrapper,它适用于该网站的桌面版。

但在移动设备方面,我们确实遇到了一个大问题。然后,当我单击输入字段时,会显示日期选择器,并且还会显示使用一半屏幕的移动键盘。

目前我们的指令看起来像这样(CoffeeScript):

"use strict"

angular.module("theapp").directive "datePicker", ->
  restrict: 'EA'
  scope:
    model: '='
    name: '@'
    required: '@'
    options: '='
  template: '<input type="text" ui-date="dateOptions" ng-model="model" ng-required="{{ required }}">'
  replace: true
  link: (scope, element, attrs) ->
    scope.required ?= false

    scope.dateOptions =
      dateFormat: "dd.mm.yy"
      yearRange: "1900:-0"
      changeYear: true
      changeMonth: true
      regional: "de"
    _.extend(scope.dateOptions, scope.options)

到目前为止我尝试了什么:

  • 一旦获得焦点就模糊​​输入字段。 结果:手机键盘闪烁两次。
  • 将类型从文本更改为按钮。 结果:它在桌面上运行良好,但在移动设备上却不行。也许我在这里做错了什么。

有人知道如何解决这个问题的好方法吗?

谢谢!

【问题讨论】:

    标签: javascript angularjs coffeescript jquery-ui-datepicker


    【解决方案1】:

    在输入中添加readonly="readonly",键盘将不再在移动设备上弹出(仅在 iPhone 上测试):

    <input type="text" id="date_picker" readonly="readonly" />
    

    【讨论】:

    • 这只是一个不错且简单的解决方案。现在唯一的问题是没有模糊动作,所以日期选择器会消失。但我想我可以解决这个问题。如果你有想法,请告诉我
    猜你喜欢
    • 2011-10-28
    • 1970-01-01
    • 1970-01-01
    • 2010-10-04
    • 2012-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多