Skip to content

Instantly share code, notes, and snippets.

Created November 27, 2017 12:32
What would you like to do?
Create modal window in drupal 8 using Drupal.dialog function
/** EXAMPLE 1 ***/
var $myDialog = $('<div>My dialog text</div>').appendTo('body');
Drupal.dialog($myDialog, {
title: 'A title',
buttons: [{
text: 'Close',
click: function() {
url: 'some/path',
success: function(response) {
var $myDialog = $('<div>' + + '</div>').appendTo('body');
Drupal.dialog($myDialog, {title: 'Some title'}).showModal();
Copy link

dalin- commented Nov 22, 2021

@ilechcod Yes. This is just how to work with simple HTML snippets.

If you want to do AJAX, you probably want:

Copy link

This is brilliant. So clear and easy to follow. No more ugly Javascript popups!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment