Ajax事件无法正常运行

时间:2015-07-09 11:18:58

标签: drupal drupal-7 drupal-modules

带有ajax调用的按钮

$form['add_product_button'] = array(
    '#type' => 'submit',
    '#value' => t('Add product'),
   // '#submit' => array('uc_order_pane_products_select'),
    '#ajax' => array(
      'callback' => 'uc_order_pane_products_ajax_callback',
      'wrapper' => 'product-controls',
    ),
  );

ajax功能

function uc_order_pane_products_ajax_callback($ form,& $ form_state){

 $newtable = uc_order_product_select_form();
 $commands[] = ajax_command_prepend('#product-controls', render($newtable));
 return array('#type' => 'ajax', '#commands' => $commands);
 }

功能 - uc_order_product_select_form()

function uc_order_product_select_form()             {

       $form['new_order'] = array(
      '#type' => 'fieldset',
      '#title'=>t(' Quantiy'),
         );

       $form['new_order']['add_order_text'] = array(
         '#type' => 'textfield',
          '#title' => t('Add Quantity'),
          );

               $form['new_order']['select_div'] = array(
                '#type' => 'submit',
                '#submit'=> 'uc_order_pane_products_ajax_callback1',
                '#value' => t('Add to Order'),
              // '#attributes' => array('onclick' => 'return uc_order_pane_products_ajax_callback1;'),
                   '#ajax'=>array(
                            'callback' => 'uc_order_pane_products_ajax_callback1',
                            'wrapper' => 'product-controls',
                              ),
                 );
        return $form;
      }

function uc_order_pane_products_ajax_callback1()
{
  print "success";
}

0 个答案:

没有答案