By adding notification before the replacement like
and another one after:
where 'newElement' is the newly created element gives a chance to the JS library to react.
The code above was my first attempt. Then I realized that custom JS events will be much better, but it appears IE doesn't support "unknown" events. There are workarounds like http://stackoverflow.com/questions/5342917/custom-events-in-ie-without-using-libraries but this code uses custom node traversal for event attaching as well which bothers me, I'm not sure what is the performance difference.
So now I'm back on the approach with registered handlers but I think it will be better if it is made general. By passing the 'eventType' (like "wicket.dom.node.remove") as a parameter to the handler it may decide whether to react. Otherwise now we have pre/post/failure handlers for Ajax and who knows what else will be needed in the future.