I have a code that allows the modal to delay. And, if the user click on either YES (which has an id="closemodal"), or NO (which has data-dismiss="modal") link, the modal will not show up again until the user leaves the page and then comes back to the same page.
<script type="text/javascript">
$(document).ready(function() {
setTimeout(function(){
$('#myModal').modal('show');
}, 10000);
$('#closemodal').click(function() {
$('#myModal').modal('hide') });
});
</script>
But, what I want is that the modal doesn't show back up at all after being shown once already to the user. I found this post. I have combined it with my code as shown below.
But, I can't seem to get this to work. Any help is appreciated.
<script type="text/javascript">
$(document).ready(function() {
if($.cookie('msg') != null && $.cookie('msg') != "")
{
$("div#myModal.modal, .modal-backdrop").hide();
}
else
{
setTimeout(function(){
$('#myModal').modal('show');
}, 10000);
$.cookie('msg', 1 ); //moved this up and changed 'str' to 1
$('#closemodal').click(function() {
$('#myModal').modal('hide'); });
}
});
</script>
Any help would be greatly appreciated.
UPDATED: Just in case this helps anyone. This is what I ended up with with the help of this post.
<script type="text/javascript">
if($.cookie('prepare') != 'seen'){
$.cookie('prepare', 'seen', { expires: 365, path: '/' }); // Set it to last a year, for example.
setTimeout(function(){
$('#myModal').modal('show');
}, 1000);
$('#closemodal').click(function() // You are clicking the close button
{
$('#myModal').modal('hide'); // Now the pop up is hiden.
});
$('#myModal').click(function(e)
{
$('#myModal').fadeOut();
});
};
</script>