The easiest way to get it to re-attach is to put in an open top shallow container with a small layer of rubble rock, then cover the container with some netting to keep it from drifting away. Then put it in a low flow / low-medium light area in the tank.
If it's fluid that's dissolves away, it could be dispelling some of it's zooxanthella. These are algae that live inside the coral and provide it energy via their photosynthesis. Corals can regulate how much is in their tissues by expelling them. It could be doing this because of a change in lighting or from stress.
If it looks like its spewing it's stringy guts out, but they are still attached to the mushroom. This could be it's mesenterial filaments. Which are it's digestive parts. These filaments have nemocyst (stinging cells). Mushrooms can do this as a defensive measure. As Davy mentioned, they can do this as a response to a physical disturbance, but they will also do this if the water parameters or off.