I want to display a form in CTool modal dialog, but failing badly.

When I click link to show modal form, ajax request is started:

POST http://drupal.dev/my_mod/arg1/ajax/arg3

and returns:

Error: Syntax error, unrecognized expression: <div id="ctools-modal"> 
<div class="ctools-modal-dialog">      <div class="modal-content">    
<div class="modal-header">          <button type="button"
class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 id="modal-title" class="modal-title">&nbsp;</h4>        </div>    
<div id="modal-content" class="modal-body">        </div>      </div> 
</div>  </div>

I tried to click different link, but gets an error:

TypeError: Drupal.CTools.Modal.modal is undefined


function my_mod_menu() {
  return array(
    'my_mod/%/%ctools_js/%' => array(
      'title' => 'Entity Modal Edit',
      'page arguments' => array(1,3),
      'page callback' => 'my_mod_modal_page_callback',
      'access callback' => 'my_mod_modal_access_callback',
      'access arguments' => array(1,2,3),
      'type' => MENU_CALLBACK,

function my_mod_modal_page_callback($entity_type, $id) {

  $form_state['user'] = user_load($id);
  $output = ctools_modal_form_wrapper('my_mod_form', $form_state);
  ctools_modal_render('Edit', $output);

I'm creating my edit link in custom views_field_handler:

class my_mod_handler_field_links extends views_handler_field {

  function init(&$view, &$options) {
    parent::init($view, $options);

    if (! isset(self::$some_property)) {

  function render($values) {

    $edit_link = array(
      'href' => 'my_mod_ctools/some_value1/nojs/some_other_value',
      'title' => t('edit'),
      'attributes' => array('class' => array('mymod-ctools-links', 'ctools-use-modal', 'use-ajax')),

    $links[] = $edit_link;

    $build = array(
      '#prefix' => '<div class="mymod-ctools-links-wrapper">',
      '#suffix' => '</div>',
      '#theme' => 'links',
      '#links' => $links,
    return drupal_render($build);

  function query() {}


I had using jQuery 1.9. I changed it to 2.1 and the problem is solved (jquery_update module)

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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