I don't know if I'm doing anything wrong or if I need to load something additionally (ahah.js?) when I add the popups but I can't for the life of me get #ahah components of a form to function if they're in a popup from the popup api.

They work fine when the page is accessed directly (not via a popup) just when I use popup's they no longer function.

Is this because of a similar issue to the WYSIWYG issue?

Fantastic otherwise :)

Comments

virtualdrupal’s picture

Category: support » bug

I don't think this issue has been addressed yet by the maintainer, but here's one more vote to make it a priority...

nhck’s picture

Issue tags: +ahah, +forms api

This is an issue for me as well - I tried some things, but couldn't get it to work.

Also note that #ahah is part of the forms api:
http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...

georgir’s picture

The reason it isn't working is because the ahah behavior requires some settings in the Drupal.settings.ahah javascript variable. The popups module shows only the content of the page and not its scripts and settings that were added with drupal_add_js.

A little too complex to solve for the general case, so I use the following snippet specifically for ahah settings, added to the top of the popups_render_as_json function

  $settings = array();
  $js = drupal_add_js();
  foreach($js['setting'] as $setting) {
    if(isset($setting['ahah'])) $settings[]=array('ahah'=>$setting['ahah']);
  }
  $settings = $settings ? drupal_get_js(null,array('setting'=>$settings)) : '';
  $content = $settings . $content;

Make sure you also have misc/ahah.js in the additionalJavascript array in your hook_popups in case your main page doesn't always include it.

Ericmaster’s picture

I tried this with no luck, I'm also loading mis/ahah.js on every request, any other suggestion? are there any specific popup options I need to set?

adavis.co.uk’s picture

I also had this problem but solved it by hacking the source of function theme_popup_ahah_placeholder() in popup_module.php. The line

'<a href="/ahah/popup/' . $type . '/' . $hash . '"></a>' .

references /ahah/popup/etc using an absolute path, which won't work if your site is running in a sub folder like mine was so I changed it to

'<a href="'.base_path().'/ahah/popup/' . $type . '/' . $hash . '"></a>' .

And it worked fine.