summaryrefslogtreecommitdiff
path: root/modules/poll
diff options
context:
space:
mode:
Diffstat (limited to 'modules/poll')
-rw-r--r--modules/poll/poll.module10
-rw-r--r--modules/poll/poll.test19
2 files changed, 17 insertions, 12 deletions
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 26236fd7d..b8493a397 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -263,14 +263,14 @@ function poll_form($node, $form_state) {
}
// We name our button 'poll_more' to avoid conflicts with other modules using
- // AHAH-enabled buttons with the id 'more'.
+ // AJAX-enabled buttons with the id 'more'.
$form['choice_wrapper']['poll_more'] = array(
'#type' => 'submit',
'#value' => t('More choices'),
'#description' => t("If the amount of boxes above isn't enough, click here to add more choices."),
'#weight' => 1,
'#submit' => array('poll_more_choices_submit'), // If no javascript action.
- '#ahah' => array(
+ '#ajax' => array(
'callback' => 'poll_choice_js',
'wrapper' => 'poll-choices',
'method' => 'replace',
@@ -320,7 +320,7 @@ function poll_more_choices_submit($form, &$form_state) {
// Make the changes we want to the form state.
if ($form_state['values']['poll_more']) {
- $n = $_GET['q'] == 'system/ahah' ? 1 : 5;
+ $n = $_GET['q'] == 'system/ajax' ? 1 : 5;
$form_state['choice_count'] = count($form_state['values']['choice']) + $n;
}
}
@@ -373,9 +373,7 @@ function poll_choice_js($form, $form_state) {
// Prevent duplicate wrappers.
unset($choice_form['#prefix'], $choice_form['#suffix']);
- $output = theme('status_messages') . drupal_render($choice_form);
-
- drupal_json(array('status' => TRUE, 'data' => $output));
+ return theme('status_messages') . drupal_render($choice_form);
}
/**
diff --git a/modules/poll/poll.test b/modules/poll/poll.test
index f5b018095..a5f668efa 100644
--- a/modules/poll/poll.test
+++ b/modules/poll/poll.test
@@ -340,17 +340,24 @@ class PollJSAddChoice extends DrupalWebTestCase {
// @TODO: the framework should make it possible to submit a form to a
// different URL than its action or the current. For now, we can just force
// it.
- $this->additionalCurlOptions[CURLOPT_URL] = url('system/ahah', array('absolute' => TRUE));
+ $this->additionalCurlOptions[CURLOPT_URL] = url('system/ajax', array('absolute' => TRUE));
$this->drupalPost(NULL, $edit, t('More choices'));
unset($this->additionalCurlOptions[CURLOPT_URL]);
// The response is drupal_json, so we need to undo some escaping.
- $response = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $this->drupalGetContent()));
- $this->assertTrue(is_object($response), t('The response is an object'));
- $this->assertIdentical($response->status, TRUE, t('Response status is true'));
- // This response data is valid HTML so we will can reuse everything we have
+ $commands = json_decode(str_replace(array('\x3c', '\x3e', '\x26'), array("<", ">", "&"), $this->drupalGetContent()));
+
+ // The JSON response will be two AJAX commands. The first is a settings
+ // command and the second is the replace command.
+ $settings = reset($commands);
+ $replace = next($commands);
+
+ $this->assertTrue(is_object($settings), t('The response settings command is an object'));
+ $this->assertTrue(is_object($replace), t('The response replace command is an object'));
+
+ // This replace data is valid HTML so we will can reuse everything we have
// for HTML pages.
- $this->content = $response->data;
+ $this->content = $replace->data;
// Needs to be emptied out so the new content will be parsed.
$this->elements = '';