I've been using Dialog for a while now, and this is an example of my standard way of requesting a form to be rendered in Dialog popup:

  $class = array();
  $attributes = array();

  drupal_add_library('dialog', 'drupal.dialog.ajax');
  drupal_add_library('system', 'drupal.ajax');
  $attributes['data-dialog'] = 'true';
  $attributes['data-dialog-options'] = '{"width":"50%"}';
  $class[] = 'use-ajax';
  $attributes['class'] = $class;

  $output = '';
  $output .= l($value, 'btp-comm-edit/' . $entity_id . '/' . $comm_op . '/' . $value, array('attributes' => $attributes));

  return $output;

This works fine on any pre rendered page.

Problem is, when I put this in a block (panel pane, mini-panel, Views. etc), which is updated with a jQuery call using $.ajax() then it just is a normal link, no popup.

Looks like the link lose focus. Or some script gets lost. I've been searching for solutions, but can't find any. I hope somebody can help.

  • Could it be the modal is outside the page margins? Where is the "standard" code, and where are you putting the code for it to be applied to a block? In Chrome DevTools (or browser's equivalent): check the console for errors. See what scripts are loaded when it works vs when it doesn't. Look at the JavaScript files used by Dialog: Check if the elements/classes/IDs for the selectors used to show the modal form are actually on the page. Add console.log() lines to compare between working/non-working pages, things like variables, objects "captured" by selectors, results from ajax requests, etc. – runswithscissors Jan 13 at 14:23

Your Answer

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

Browse other questions tagged or ask your own question.