I am trying to use the Drupal 8 Modal API to output a link in a modal window - using the "Simple Link" approach here.

When clicking my link, I get a little animated spinner and I can see the response being returned via ajax using my browser inspector. However, no modal appears? There are no errors output to the console.

I am using a custom theme - is there some mark up I must place in the theme, to act as a container for the modal?


After some more research, I found the solution in a comment on this article - basically, every article I could find on the subject seems to have been written prior to some API changes being made, in how a dialog or modal is invoked.

An example link would be:

<a href="/blah" class="use-ajax" data-dialog-type="modal" data-dialog-options="{"width":500}">Show me a 500px wide modal</a>

So, the key thing is that data-accepts attribute is replaced with data-dialog-type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy