Javascript / jquery - Re-allow opening a modal after hiding it -


i used this question hiding modal after clicked outside it.

$(document).mouseup(function (e) {     var container = $(".messenger");      if (!container.is(e.target) // if target of click isn't container...         && container.has(e.target).length === 0) // ... nor descendant of container     {         container.hide();     }  }); 

in comments, rightfully said have add something, if not can't open modal again after has been hidden once

remembering use $("your container selector").unbind( 'click', clickdocument ); beside .hide(). document don't keep listening clicks. – brasofilo

so added line

$(document).mouseup(function (e) {     var container = $(".messenger");      if (!container.is(e.target) // if target of click isn't container...         && container.has(e.target).length === 0) // ... nor descendant of container     {         container.hide();         container.unbind( 'click', clickdocument );//the line added     }  }); 

but not work. if click again button, modal not reappear anymore.

rookie in javascript. doing wrong ?

edit

the script managing opening of modal not custom. use hubspot messenger:

so write code.

var msg; msg = messenger().post({   message:      'this si message inside modal',   hideafter:    2500,   showclosebutton: true,   type: 'skip' });  


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -