I'm having a requirement where I have to show popup on the click link. and then after that pop up open need to show related content on that pop-up. this part is working. by doing this

<a class="use-ajax" data-dialog-type="modal" href="/node/{{ nid }}">

so when I click related content I again need to show a popup and close the old one. this case not working

I know there is CloseModalDialogCommand but how to use in this case as I have

    <a class="use-ajax" data-dialog-type="modal" href="/node/{{ nid }}">

this link for related content also

1 Answer 1


As per my understanding you want to open a new modal from an existing open modal. I have checked the same case in latest drupal 8.7.5 and it works without a problem. You don't have to add any additional script to do this. I would recommend you to debug it and check the exact problem that is preventing popup to open and close existing one. You can follow the below steps to debug it-

  1. Create any of 2 dummy articles like below and link one with another one.

First Article:-

Title - Dummy Article 1    
Body - <a class="use-ajax" data-dialog-type="modal" href="/node/2">Click Article 2</a>   
Text Format - Full HTML   
URL - node/1

Second Article:-

Title - Dummy Article 2
Body - <a class="use-ajax" data-dialog-type="modal" href="/node/1">Click Article 1</a>
Text Format - Full HTML
URL - node/2

Open/View any of the above created article to check if the problem is with the modal or related with any other issue. Check browser console if in case modal doesn't open.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.