Prevent modal from shut down

Well, it does for me :thinking:
Kapture 2022-01-07 at 14.55.37

How did you manage to get it work now?

Code works for me, and it works on Modal Designer, as I stated, but the .modal-backdrop was closing, the modal was staying open.

There isn’t anything special with the code. It just adds a Bootstrap attribute on the correct Div.

Adding @PeteSharp script. It’s not working when adding custom attributes. @Norm will need to look into this.

1 Like

It works with OLDER projects migrated from BS4 to BS5?

There is no reason for it not too.

Got a live link I can look at?

Well, Modal designer is not working on BS4 :thinking: :grin:

How many modals do you have on the page @Bootsie. The code will only apply it to the first one in the DOM. I just realised.

Plenty.
Have a look here:

@Bootsie, works on the Facebook Icon fine (which is the first modal in the DOM).
The code is only adding it to the first modal instance.

If you have multiple modals, the code needs to be slightly different to run through all of them.

wow,
never realized.
Do you have an idea how to change the code?

What happens when you remove your cookie expiry script? There could be a conflict.

@Bootsie, this will add the attribute to every Modal instance on the page.

<script>
window.addEventListener('load',() => {
  modal = document.querySelectorAll('.modal');
  modal.forEach(function(modal){
  		modal.setAttribute('data-bs-backdrop', 'static');
  });
});
</script>
2 Likes

That’s it. Works as it should.
Removing the cookie expiry script had no effect.
Thanks a lot guys.

2 Likes