0

I need to get form only with HTML. To do this, I've used delivery callback in hook_menu(). This is my sample code:

function test_menu() {
  $items['htmlform'] = array(
   'access callback'  => TRUE,
   'page callback'    => 'test_htmlform'
   'delivery callback' => 'delivery_text_plain',
   'type'             => MENU_CALLBACK,
 );
  return $items;
}

In this form, I've used #states and #ajax.

I've another form which is in the normal callback. I need to show htmlform into this Drupal form. So I've written a ajax callback to 'htmlform', get html, paste it into the drupal form & show this in pop up.

This is my ajax callback:

$.ajax({
    url: '/htmlform',
    success: function(data) {
      $('#formpopup').empty();
      $('#formpopup').html(data);
      $("#form_demo_pup").modal({backdrop: 'static',keyboard: false});
      Drupal.attachBehaviors($('#form_demo_pup'));
    }
  });

Now the drupal form page have all the CSS and JavaScript but the pop up (htmlform) have only the HTML.

On this pop-up, #states and #ajax are not working since it has no Drupal form JavaScript.

How do I fix this? Even I tried "Drupal.attachBehaviors" in my custom ajax.

1 Answer 1

0

You need to load the required JS on page load, not on Ajax load. You will need to load the Drupal.ajax library as well.

1
  • Already I've loaded required JS file on the page.
    – Guru
    Commented Nov 24, 2016 at 14:48

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.