Content modal opening by link or url parameters

In by dhunink

Back to Code Snippets
When using the V2 Element 'Content modal' you may find yourself wanting to open/close the modal by something else then the default button. This script enables you to do so. Steps: 1. Give the modal a unique ID 2. Set the ID as href on your link: ?x-toggleable-target=modal-id 3. To close any previous openend modal, append the following to your link: x-toggleable-closeall So for example: Appending these to an url will work as well: http://mywebsite.com/?x-toggleable-target=unique-modal-id
Submitted by: dhunink
Language JavaScript