По-видимому, средство выбора даты не позволяет браузеру запускать событие размытия после того, как он потерял фокус, щелкнув мышью.
Это вызывает событие размытия, только если вы продолжаете перемещаться по вкладке, чтобы потерять фокус, или изменяя значения, выбирая дату.
Таким образом, в основном обходной путь может эмулировать событие размытия, используя щелчок/фокус другого элемента.
Обходной путь
$(document).ready(function () {
$(".focus-popover").each(function (index) {
var showPopover = function () {
$(this).popover('show');
};
var hidePopover = function () {
$(this).popover('hide');
};
$(this).popover({
html: true,
placement: $(this).attr('data-placement'),
trigger: 'manual'
})
.focus(showPopover)
.blur(hidePopover);
})
// The nasty Opera < 12 "workaround"
if ( window.opera && +window.opera.version() <= 13 ) {
var $buggyInput = $("#test2"), // Caching is important!
buggyInputFocus = false,
buggyFocus = function(event) {
event.stopPropagation();
if(!buggyInputFocus) {
$(this).popover('show');
buggyInputFocus = true;
}
},
buggyBlur = function(event) {
$(this).popover('hide');
buggyInputFocus = false;
}
;
// The focus also stop triggering if it was blurred then clicked back, so we added a click. It doesn't run buggyFocus twice since it only execute itself if it hasn't been focused first
$buggyInput.on({
"focus": buggyFocus,
"click": buggyFocus,
"blur":buggyBlur,
"change":buggyBlur // On change is also important, you don't want to leave it open when it changes
})
// Since it doesn't the blur event, we fake it by capturing focus or click on the html tag
$("html").on({
click: function() {
if ( buggyInputFocus ) $buggyInput.trigger("blur");
},
focus: function() {
if ( buggyInputFocus ) $buggyInput.trigger("blur");
}
})
}
});
Скрипт: http://jsfiddle.net/5wsq38u3/4/
РЕДАКТИРОВАТЬ: Для ввода более 1 даты
$(document).ready(function () {
$(".focus-popover").each(function (index) {
var showPopover = function () {
$(this).popover('show');
};
var hidePopover = function () {
$(this).popover('hide');
};
$(this).popover({
html: true,
placement: $(this).attr('data-placement'),
trigger: 'manual'
})
.focus(showPopover)
.blur(hidePopover);
})
// The nasty Opera < 12 "workaround"
if (window.opera && +window.opera.version() < 13) {
var $buggyInputs = $(".operaFix"), // Caching is important!
buggyInputFocus = false,
buggyInput = {}, // We store an instance of the focused element
buggyFocus = function(event) {
event.stopPropagation();
if(!buggyInputFocus) {
$(buggyInput).popover('hide');
$(this).popover('show');
buggyInputFocus = true;
buggyInput = $(this);
}
else if ($(buggyInput).attr("id") !== $(this).attr("id")){
$(buggyInput).trigger("blur")
}
},
buggyBlur = function(event) {
$(this).popover('hide');
buggyInputFocus = false;
buggyInput = {}
}
;
// The focus also stop triggering if it was blurred then clicked back, so we added a click. It doesn't run buggyFocus twice since it only execute itself if it hasn't been focused first
$buggyInputs.on({
"focus": buggyFocus,
"click": buggyFocus,
"blur": buggyBlur,
"change": buggyBlur // On change is also important, you don't want to leave it open when it changes
})
// Since it doesn't the blur event, we fake it by capturing focus or click on the html tag
$("html").on({
click: function() {
if (buggyInputFocus) $(buggyInput).trigger("blur");
},
focus: function() {
if (buggyInputFocus) $(buggyInput).trigger("blur");
}
})
}
});
JSBin: http://jsbin.com/xucagomutera/1/edit
person
jsachs
schedule
03.09.2014
</input>
. - person cvrebert   schedule 03.09.2014