Follow these steps:

1) Click on create content >> whatever you want
2) Upload an image
3) Check de image, and the push the Delete button

This causes the form to submit, instead of doing the ajax call, and the item is not deleted.
Seems that when you upload an image, the image_upload_js function rebuilds the form, and the ahah of the Delete button does not work.
You can check this because after uploading an image the class of the Delete button is class="form-submit" instead of class="form-submit ahah-processed".

When the form is fully submitted, then the Delete button class is class="form-submit ahah-processed" and it works.

Maybe the del button ahah content doesn't work if it hasn't been initialized in the $(document).ready because it didn't exists in the .ready event.
Perhaps loading initially the button as "hidden" may be a solution ?

Comments

savioret’s picture

Title: ahah-processed class not working when deleting an item » Delete button not working properly

I can confirm that rendering the Delete Button (in hidden mode if there's no images to list) in the first form load solves the problem.

bojanz’s picture

Could I get this as a patch, please?

savioret’s picture

Sorry I haven't done it. Just changed the delete button creation position (to be always created) and I noticed that It worked.

selvakumar’s picture

Before sending the response to JSON...Add the following lines...
==========
// AHAH is not being nice to us and doesn't know the "other" button (that is,
// either "Upload" or "Delete") yet. Which in turn causes it not to attach
// AHAH behaviours after replacing the element. So we need to tell it first.

// Loop through the JS settings and find the settings needed for our buttons.
$javascript = drupal_add_js(NULL, NULL);
$filefield_ahah_settings = array();
if (isset($javascript['setting'])) {
foreach ($javascript['setting'] as $settings) {
if (isset($settings['ahah'])) {
foreach ($settings['ahah'] as $id => $ahah_settings) {
if (strpos($id, 'ahah-more') || strpos($id, 'ahah-remove')) {
$filefield_ahah_settings[$id] = $ahah_settings;
}
}
}
}
}

// Add the AHAH settings needed for our new buttons.
if (!empty($filefield_ahah_settings)) {
$output_settings = '

jQuery.extend(Drupal.settings.ahah, '. drupal_to_js($filefield_ahah_settings) .');

';
}
========