【问题标题】:In Bootstrap UI datepicker focus is not returning back to the date field when clicked on a date在 Bootstrap UI 中,日期选择器焦点在单击日期时不会返回到日期字段
【发布时间】:2017-01-24 05:54:53
【问题描述】:

当我点击Today, clearclose 按钮时,焦点又回到date field。 当我点击任何特定日期时,我想要相同的功能。

【问题讨论】:

标签: angularjs datepicker jquery-ui-datepicker bootstrap-datepicker


【解决方案1】:

我调试了这个问题。发现在日期选择器本身中,不存在在选择日期后将焦点重新集中在日期字段上的功能。
日期选择器弹出窗口:http://angular-ui.github.io/bootstrap/

发现在文件:datepicker.js 中,当我们点击任何日期时,函数$scope.select = function(date) 会被触发,这反过来会广播一个事件$scope.$broadcast('uib:datepicker.focus');,该事件在我们的代码中的任何地方都没有被捕获。

下面是要修复的代码:

  var focusElement = function() {
    self.element[0].focus();
  };

  // Listen for focus requests from popup directive
  $scope.$on('uib:datepicker.focus', focusElement);

有帮助的链接:https://github.com/angular-ui/bootstrap/blob/master/src/datepicker/datepicker.js#L213

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-23
    • 1970-01-01
    • 1970-01-01
    • 2015-03-26
    • 1970-01-01
    • 1970-01-01
    • 2012-05-29
    • 1970-01-01
    相关资源
    最近更新 更多