I have code in my code that closes the window when I click outside the window, but the trouble is that inside this window there is a calendar that is needed for work, so when you click on this calendar, the window closes and trouble happens!

How to fix?

Bug:

enter image description here

Window closing code:

$(document).mouseup(function (e){ // событиС ΠΊΠ»ΠΈΠΊΠ° ΠΏΠΎ Π²Π΅Π±-Π΄ΠΎΠΊΡƒΠΌΠ΅Π½Ρ‚Ρƒ if (!modal_content.is(e.target) // Ссли ΠΊΠ»ΠΈΠΊ Π±Ρ‹Π» Π½Π΅ ΠΏΠΎ Π½Π°ΡˆΠ΅ΠΌΡƒ Π±Π»ΠΎΠΊΡƒ && modal_content.has(e.target).length === 0) { // ΠΈ Π½Π΅ ΠΏΠΎ Π΅Π³ΠΎ Π΄ΠΎΡ‡Π΅Ρ€Π½ΠΈΠΌ элСмСнтам $modal.find('.modal-body').empty().end(); mcloced(addclassmodal); } }); 

    1 answer 1

     $(modal_content).on('mouseup', function (e) { e.preventDefault(); }) 
    • 2
      rather stopPropagation - Grundy
    • so put the odd did not help ... $ (modal_content) .on ('mouseup', function (e) {e.stopPropagation (); // event of clicking on the web document $ modal.find ('. modal-body') .empty (). end (); mcloced (addclassmodal);}); - Alexander Sizintsev
    • @moonvvell even does not work - Alexander Sizintsev