Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm trying to make a ahah form. the problem is the ahah is ignored. when i check the classes on the submit button, it doesn't have the 'ahah-processed' class. The really interesting thing is that ahah is working perfectly on my site, and even on a nearly identical form I created. this is how i'm creating the ahah submit button:

$form['ri_email_submit'] = array(
        '#type' => 'submit',
        '#value' => t('Submit'),
        '#weight' => 1,
        '#submit' => array('ri_email_form_submit'),//none JS version
        '#ahah' => array(
          'event' => 'click',
          'path' => 'ri_email/ajax',
          'wrapper' => 'email-friend-wrap',
          'method' => 'replace',
          'effect' => 'fade',
          'progress' => array(
            'type' => 'bar',
            'message' => t('Loading...')
          )      
        )
        );

I checked the menu path, it's correct.

UPDATE: this is the menu callback:

function ri_email_ajax() {
    return drupal_json(array('status' => TRUE, 'data' => '<p><strong>Your email has been sent.</strong><p>'));   }

by the way, i discovered that it didn't work when i invoked drupal_get_form() from page.tpl.php, but it does work from node.tpl.php

there is something missing with the javascript that is supposed to handle the ahah

share|improve this question
    
Please read How to Ask and learn how you can give back to community by accepting answers. –  Chapabu Oct 8 '12 at 8:45
    
I second your request Chapabu. –  cayerdis Dec 7 '12 at 20:14
add comment

1 Answer

Can you post the callback function generating the page at 'ri_email/ajax'?

It should look something like this:

<?php
  function awesome_ahah_callback() {
    $thing_to_process = $_POST['thingfromform']
    /* do stuff, including generating some kind of $processed_data variable */

    drupal_json(array(
      'status' => TRUE, 
      'data' => $processed_data,
    ));
    exit();
  }
?>

If you aren't generating the thing you want to send back through AHAH with drupal_json and then calling exit() then I don't think it will work.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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