Why the popup disappears?

Hello!

The filter did drop down a level: filter by date. It was necessary to make that it was lost by clicking outside the field. This problem was solved by the next way:

$(document).on('click', function(e) {
 if (!$(e.target).closest('.js-filter-dropdown').length && !$(e.target).hasClass('js-toggle-dropdown')) {
 $('.js-toggle-dropdown').each(function(){ 
$(this).removeClass('js-toggle-dropdown-active');
});
 $('.js-filter-dropdown').each(function(){ 
$(this).removeClass('js-toggle-dropdown-open');
$(this).fadeOut(300);
});
};
 });


All is good, but there are problems with the calendar it places the shooter: 5c9a30bcbcef7712571859.png
I use datepicker from jqueryUi
If they press the pop-up window also disappears. In any other place, whether calendar or not - everything is OK. what could be wrong?
March 19th 20 at 08:41
2 answers
March 19th 20 at 08:43
so try to make

$('body').click(function(event){
 if ($(event.target).closest('// write here the class which does not need to respond to a click outside the field').length) return;
 $('// here the class which I need to delete something').removeClass('// here the class is used to delete');
 event.the stoppropagation(); 
 });
So?
$('body').click(function(e){

 if ($(e.target).closest('.js-filter-dropdown').length) return;
 if ($(e.target).hasClass('js-toggle-dropdown')) return;

 $('.js-toggle-dropdown').each(function(){ 
$(this).removeClass('js-toggle-dropdown-active');
});

 $('.js-filter-dropdown').each(function(){ 
$(this).removeClass('js-toggle-dropdown-open');
$(this).fadeOut(300);
});

 event.the stoppropagation(); 

 });
- karina.Joh commented on March 19th 20 at 08:46
The problem remained, hiding - karina.Joh commented on March 19th 20 at 08:49
@karina.Joh, I wrote to you an example. Just put your classes - Reagan.Runte commented on March 19th 20 at 08:52
@Reagan.Runtedoes not help in General your option. - karina.Joh commented on March 19th 20 at 08:55
March 19th 20 at 08:45
The arrows do not link
what will change? - karina.Joh commented on March 19th 20 at 08:48
@karina.Joh, will cease to disappear "popup" - madaline.Gibson46 commented on March 19th 20 at 08:51
@madaline.Gibson46, it's good! And how it is to make a datepicker - karina.Joh commented on March 19th 20 at 08:54
@madaline.Gibson46, I like your prediction. But tell me what physics is this? Will love to have there links default behavior is disabled. Then what is it? - karina.Joh commented on March 19th 20 at 08:57
@karina.Joh, the default action is not canceled there. Cancel your script - madaline.Gibson46 commented on March 19th 20 at 09:00
@madaline.Gibson46, did not help - karina.Joh commented on March 19th 20 at 09:03

Find more questions by tags jQueryJavaScript