0

I made a fullscreen overlay with a popup. Now when I press the button I want a popup to be set. You can also click outside the window. Then the popup disappears. I want a cookie to be set there as well. Somehow I do not understand the whole thing. Here is my code:

$(function() {
  $("#custom-modal").modal("show");
});

/* Close the popup when the a selection is made */
$("#selectCity").on("change", function() {
  $("#custom-modal").modal("hide");
});


$.modal({

  // enable/disable cookies
  cookie: true,

  // cookie name
  cookieName: 'eisstadion',

  // enable/disable cookie session
  cookieSession: true,

  // expire time
  cookieExpires: 30,

  // cookie path
  cookiePath: '/'

});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- A Bootstrap Modal -->
<div id="custom-modal" class="modal fade" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Achtung!</h4>
      </div>
      <div class="modal-body">
        Ab sofort nur noch Online die Tickets
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Hier gehts zum Shop</button>
      </div>
    </div>
  </div>
</div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
  • 1
    I made you a snippet. You are mixing bootstrap modals with jQuery UI modals – mplungjan Sep 30 '20 at 13:09
  • 1
    Add the cookie code in a callback but don't use cookies if you do not need to read the value on the server: `$("#custom-modal").on('shown.bs.modal', function (e) { localStorage.setItem("eisstadion","yes") })` – mplungjan Sep 30 '20 at 13:15
  • @mplungjan: thats friendly - thank you for that. – Patrick Dierig Sep 30 '20 at 13:25

0 Answers0