Ajax event not working as expected

Button with ajax call

$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

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);
 }

      

function - 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";
}

      

+3


source to share





All Articles