0

I am using the jQuery plugin Remodal to create a modal for my website. I am following the documentation on their website however I am running into an issue with opening and closing the modal. If I open the modal then refresh my browser the next time the page loads the modal will still be open. I created an instance of the modal using var inst = $('[data-remodal-id=modal]').remodal(); and did a console.log(inst.getState()); and the modal was stuck in in the "opening" state. I also tried to run the inst.close(); function but that didnt work as well.

Here is my code:

$(document).ready(function() {
  var inst = $('[data-remodal-id=modal]').remodal();
  console.log(inst.getState()); //if I refresh with the modal open this will print "opening".
  //I want the modal to be closed every time the page is refreshed
  $('#div').click(function() {
     inst.open();
  });
  $(document).on('opening', '.remodal', function () {
    //when the modal opens open another jQuery plugin
    $("#gallery").unitegallery();
  });
});

Within my html body I have the following code:

<div data-remodal-id="modal"></div>
J. Chomel
  • 8,193
  • 15
  • 41
  • 69
ogk
  • 602
  • 4
  • 12
  • 28

1 Answers1

0

I had the same problem and solved it by setting the option hashTracking to false.

This can be done in the HTML directly, by setting data-remodal-option="hashTracking: false", or by specifying it with the options parameter when constructing the Remodal from code. See also the Remodal docs on options.

jcb
  • 382
  • 3
  • 17