diff options
Diffstat (limited to 'modules/book')
-rw-r--r-- | modules/book/book.css | 2 | ||||
-rw-r--r-- | modules/book/book.module | 5 | ||||
-rw-r--r-- | modules/book/book.pages.inc | 42 |
3 files changed, 24 insertions, 25 deletions
diff --git a/modules/book/book.css b/modules/book/book.css index 8c62e4ae9..757b4bdd2 100644 --- a/modules/book/book.css +++ b/modules/book/book.css @@ -47,7 +47,7 @@ html.js #edit-book-pick-book { #book-admin-edit select.progress-disabled { margin-right: 0; } -#book-admin-edit tr.ahah-new-content { +#book-admin-edit tr.ajax-new-content { background-color: #ffd; } #book-admin-edit .form-item { diff --git a/modules/book/book.module b/modules/book/book.module index 9f2e6f241..3b5e88868 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -490,10 +490,11 @@ function _book_add_form_elements(&$form, $node) { '#description' => t('Your page will be a part of the selected book.'), '#weight' => -5, '#attributes' => array('class' => 'book-title-select'), - '#ahah' => array( + '#ajax' => array( 'path' => 'book/js/form', 'wrapper' => 'edit-book-plid-wrapper', - 'effect' => 'slide', + 'effect' => 'fade', + 'speed' => 'fast', ), ); } diff --git a/modules/book/book.pages.inc b/modules/book/book.pages.inc index cc61821ad..3e139cd81 100644 --- a/modules/book/book.pages.inc +++ b/modules/book/book.pages.inc @@ -234,28 +234,26 @@ function book_remove_form_submit($form, &$form_state) { * Prints the replacement HTML in JSON format. */ function book_form_update() { - $cached_form_state = array(); + // Load the form based upon the $_POST data sent via the ajax call. + list($form, $form_state) = ajax_get_form(); + + $commands = array(); $bid = $_POST['book']['bid']; - if ($form = form_get_cache($_POST['form_build_id'], $cached_form_state)) { - // Validate the bid. - if (isset($form['book']['bid']['#options'][$bid])) { - $book_link = $form['#node']->book; - $book_link['bid'] = $bid; - // Get the new options and update the cache. - $form['book']['plid'] = _book_parent_select($book_link); - form_set_cache($_POST['form_build_id'], $form, $cached_form_state); - // Build and render the new select element, then return it in JSON format. - $form_state = array(); - $form = form_builder($form['form_id']['#value'] , $form, $form_state); - $output = drupal_render($form['book']['plid']); - drupal_json(array('status' => TRUE, 'data' => $output)); - } - else { - drupal_json(array('status' => FALSE, 'data' => '')); - } - } - else { - drupal_json(array('status' => FALSE, 'data' => '')); + + // Validate the bid. + if (isset($form['book']['bid']['#options'][$bid])) { + $book_link = $form['#node']->book; + $book_link['bid'] = $bid; + // Get the new options and update the cache. + $form['book']['plid'] = _book_parent_select($book_link); + form_set_cache($form['values']['form_build_id'], $form, $form_state); + + // Build and render the new select element, then return it in JSON format. + $form_state = array(); + $form = form_builder($form['form_id']['#value'], $form, $form_state); + + $commands[] = ajax_command_replace(NULL, drupal_render($form['book']['plid'])); } - exit(); + + ajax_render($commands); } |