0

I'm using modal form in drupal7.26 with WEBFORM module and is working fine when I click a link the form opens in new modal.

What I want is to open the same WEBFORM with out clicking any link instead it should be open on page/body load event.

I'm using modal form with CTOOLS and WEBFORM modules.

Any help would be appreciated.

Cheers -Zafar

0

1 Answer 1

0

I'm not sure why you would want to automatically load a modal when the page is loaded, IMO that's a bad user experience. But if you must, you can use a bit of jQuery in the theme to make it happen. Maybe something like the following:

  /**
   * Open Modal window on page load.
   */
   Drupal.behaviors.openModalOnPageLoad = {
    attach: function(context, settings) {
      // Just create some kind of ID or class for the modal link, add whatever extra
      // classes you need to be more specific if necessary.
      $(".page-node-number #myModalLink").click();
    }
  };
1
  • Might be best to use Drupal.CTools.Modal.show(). I'm not certain that click() will work on every browser. Commented Jan 31, 2016 at 1:27

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