如何關閉mouseout?
您需要取消關閉,如果您在日曆中移動到另一個DIV雖然:
//get the calendar as element
theCalendar = element[0].children[1];
// hide the calendar on mouseout
var closeCalendarTimeout = null;
angular.element(theCalendar).bind('mouseout', function() {
if (closeCalendarTimeout !== null)
$timeout.cancel(closeCalendarTimeout);
closeCalendarTimeout = $timeout(function() {
$scope.hideCalendar();
},250)
});
angular.element(theCalendar).bind('mouseover', function() {
if (closeCalendarTimeout === null) return
$timeout.cancel(closeCalendarTimeout);
closeCalendarTimeout = null;
});
編輯
添加的tabindex屬性來一個div導致其火焦點和模糊事件。
, htmlTemplate = '<div class="datepicker-calendar" tabindex="0">' +
angular.element(theCalendar).bind('blur', function() {
$scope.hideCalendar();
});
您是否嘗試過輸入ng-blur指令? – SoluableNonagon 2014-09-10 15:47:43
另外,你的plunker是完整的錯誤,請解決這些,以便其他人可以幫助你。 – SoluableNonagon 2014-09-10 15:48:57
@EliteOctagon對不起,這是一箇舊版本的角度引起的錯誤,修正:http://plnkr.co/edit/zNb65ErYH5HXgAQPOSM0?p=preview – sbaaaang 2014-09-10 15:59:46