0

I have a custom form with a managed_file field element. I'd like to call an ajax event after removing a file (clicking the REMOVE button).

Is there a way to expand the existing ajax callback for the remove button?

What I'm trying to do is fire a custom ajax event after clicking the REMOVE button on a managed_file element to remove an element from the dom.

2
  • Which Drupal version? Commented Nov 26, 2020 at 8:30
  • Drupal 8. What I'm trying to do is fire a custom ajax event after clicking the REMOVE button on a managed_file element to remove an element from the dom. Commented Nov 26, 2020 at 16:51

1 Answer 1

1

I tried to do the same in D7 a while ago and I discovered a JS only solution is not possible. You need to add an ajax command to the Drupal callback.

Here's a similar question to yours. This one is about the upload button and you want the remove button.

In D7, the upload and remove button were handled by the same function and when I look at the D8 class of the managed file I also see only one callback: uploadAjaxCallback. So it might be worth checking that out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.