Clockpicker:如何防止点击输入打开clockpicker
Clockpicker: How to prevent click on input to open clockpicker
我在我的页面上使用 weareoutman's clockpicker。如何防止在时钟选择器可见之前单击输入以显示时钟选择器或淡入淡出?我只是想在 clockpicker 显示之前淡入叠加层。单击 "button" 正在按预期工作。到目前为止,我已经在 clockpicker 中尝试过 beforeShow 函数 e.preventDefault() 和 e.stopPropagation() - jQuery.
中的函数
HTML:
<div class="dialog">
<div>Clock:</div>
<div class="input-group" id="clockpicker">
<input type="text" id="start-time" class="clock text-right" readonly />
<span class="button button-gray icon icon-clock"></span>
</div>
<div class="dialog-overlay hide"></div>
</div>
jQuery:
var clock = jQuery('#clockpicker'),
dialog_overlay = jQuery('.dialog-overlay');
clock.clockpicker({
autoclose: true,
afterDone: function() {
dialog_overlay.fadeOut('slow');
}
});
clock.on('click', function(e) {
dialog_overlay.fadeIn('slow', function() {
clock.clockpicker('show');
});
});
我找到了解决问题的方法。在输入字段中关闭点击事件。
clock.find('input').off('focus.clockpicker click.clockpicker');
我希望这个解决方案也能帮助其他人。
使用最新版本的库,您可以执行如下操作:
$('#inputId').clockpicker({
beforeShow: function e() {
var condition = "...";
if (!condition) {
e.stopPropagation();
}
}
});
我在我的页面上使用 weareoutman's clockpicker。如何防止在时钟选择器可见之前单击输入以显示时钟选择器或淡入淡出?我只是想在 clockpicker 显示之前淡入叠加层。单击 "button" 正在按预期工作。到目前为止,我已经在 clockpicker 中尝试过 beforeShow 函数 e.preventDefault() 和 e.stopPropagation() - jQuery.
中的函数HTML:
<div class="dialog">
<div>Clock:</div>
<div class="input-group" id="clockpicker">
<input type="text" id="start-time" class="clock text-right" readonly />
<span class="button button-gray icon icon-clock"></span>
</div>
<div class="dialog-overlay hide"></div>
</div>
jQuery:
var clock = jQuery('#clockpicker'),
dialog_overlay = jQuery('.dialog-overlay');
clock.clockpicker({
autoclose: true,
afterDone: function() {
dialog_overlay.fadeOut('slow');
}
});
clock.on('click', function(e) {
dialog_overlay.fadeIn('slow', function() {
clock.clockpicker('show');
});
});
我找到了解决问题的方法。在输入字段中关闭点击事件。
clock.find('input').off('focus.clockpicker click.clockpicker');
我希望这个解决方案也能帮助其他人。
使用最新版本的库,您可以执行如下操作:
$('#inputId').clockpicker({
beforeShow: function e() {
var condition = "...";
if (!condition) {
e.stopPropagation();
}
}
});