Drupal Ajax breaks after one fire This is a very frustrating and recurring problem for me because it seems to come and go at random, one minute it is working beautifully, the next moment I make a change and it breaks.  Even if I change everything back the way it was and clear the cache again it is still broken.

I have a form, in the form is a table that allows users to enter ingredients into the form.  There is a "More ingredients" button.  Once clicked an AJAX call is made and the form is rebuilt and a new row is appended to the table.  For some reason This "More ingredients" button has been broken.  On click, it adds one ingredient, then on the second click, nothing.  The button will not even trigger the receding animation as it does other buttons, it is as if the button has just disapeared...

Here is the code.

relevant form function

 if (isset($form_state['add_ingredients'])) {

//reset add ingredients under form_state
unset($form_state['add_ingredients']);

//Get number of added ingredient for proper naming below.  Allows us to use row theme instead of table theme for loading only an ingredient.
$ing_number = count($node-&gt;recipe_ingredients['ing']);

//Be sure ajax returns proper row number.
$form_state['ing_number'] = $ing_number;

//Add ingredient to our ingredients array.
array_push($node-&gt;recipe_ingredients['ing'], array('ri_id' =&gt; NULL, 'name' =&gt; '', 'quantity' =&gt; '', 'unit_key' =&gt; '',  'note' =&gt; '', 'weight' =&gt; $max_weight + 1));

//Theme this row only, uses $ing_number to designate it will only be themed by row theme function, not table.
$form['recipe_ingredients']['ing'][$ing_number] = array(
    '#theme' =&gt; 'ingredients_row',
    '#row_number' =&gt; $ing_number
    );



$form['recipe_ingredients']['ing']['1'][]
. . .

$form['recipe_ingredients']['recipe_more_ingredients'] = array(
'#type' =&gt; 'submit',
'#name' =&gt; 'ingredientadd',
'#value' =&gt; t('More ingredients'),
'#description' =&gt; t("If the amount of boxes above isn't enough, click here to add more ingredients."),
'#weight' =&gt; 1,
'#submit' =&gt; array('recipe_more_ingredients_submit'),
'#limit_validation_errors' =&gt; array(),
'#ajax' =&gt; array(
  'callback' =&gt; 'recipe_more_ingredients_js',
  'wrapper' =&gt; 'ingredient-list',
  'effect' =&gt; 'fade',
  'method' =&gt; 'append'
  )
);


Submit

function recipe_more_ingredients_submit($form, &amp;$form_state) {
//Set Drupal's form rebuild option to true...  not sure if this is really needed...
$form_state['rebuild'] = TRUE;

// If they clicked the more ingredients button, flag it in form_state['add_ingredients']
  if ($form_state['values']['recipe_ingredients']['recipe_more_ingredients']) {
   $form_state['add_ingredients'] = TRUE;
  }

}


Ajax Callback

function recipe_more_ingredients_js($form, &amp;$form_state) {

return $form['recipe_ingredients']['ing'][$form_state['ing_number']];

}


Row theming function

function theme_ingredients_row($variables) {

$form = $variables['form'];

$row_number = $form['#row_number'];

// Build the table row.
$row = array(
    'data' =&gt; array(
    drupal_render($form['ri_id']) . drupal_render($form['quantity']),
    )
  );
  $row['data'][] = drupal_render($form['unit_key']);
  $row['data'][] = drupal_render($form['name']);
  $row['data'][] = drupal_render($form['note']);
  $row['data'][] =  '&lt;button class="ing-remove" type="button"&gt;Remove&lt;/button&gt;';

//Start HTML of row  
$output = '&lt;tr ' . ' id="' . 'ing-' . $row_number . '"' . '&gt;';

//Wrap each cell in proper HTML tags
foreach ($row['data'] as $key =&gt; $value) {

    $output .= '&lt;td&gt;' . $value . '&lt;/td&gt;';

}

$output .= '&lt;/tr&gt;';

watchdog('ROW', $output, null, $severity = WATCHDOG_NOTICE);

return $output;

}
Sadly that still doesn't work...  The problem is not that php, it calls the website only the first time.  The second time the button is broken.  It does not click, call Drupal or anything.  Also any buttons added to page with ajax do not work either, even though their pre-loaded counterparts work perfectly fine with jquery.