简体   繁体   English

当聚焦于文本框时显示弹出框,模糊显示时隐藏它,但单击弹出框则不显示

[英]Show popover when focus on a textbox, hide it on blur but not if popover is clicked

My issue in simple terms: 我的问题很简单:

  • I've a text input. 我有文字输入。
  • When it gains focus, a Bootstrap "popover" will appear via jquery's .on('focus',...) 当它获得焦点时,会通过jquery的.on('focus',...)出现Bootstrap“ .on('focus',...)
  • The popover contains a form with radioboxes 弹出框包含带有单选框的表单

I want the Popover to hide on blur, but NOT when something is clicked inside the popover itself (otherway clicking on it will make the textbox lose focus and the popover disappears, making it useless). 我希望Popover隐藏在模糊状态下,但是不要在Popover本身内部单击某些东西时(否则,单击它将使文本框失去焦点,并且Popover消失,从而使其无效)。

Any ideas? 有任何想法吗?

Yeah HTML classes, .data(), boolean flags... Whatever suits you 是的HTML类,.data(),布尔标志...无论什么适合您

.on('click',...){
  1. popover.addClass('oak');
  2. popover.data('oak',true);
  3. var oak = true;

then 然后

.on('click',...,function(){
   //oak = popover.hasClass('oak');
   //oak = popover.data('oak');
   if(oak) return;
   popover.hide();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM