How To Catch Page Hide in Version 1.4.2?

How To Catch Page Hide in Version 1.4.2?

Hi:

I am trying to use version 1.4.2. In the old version, I can just do
$(document).on("#pageid", "pagehide", function(){
$("#pageid").remove();});

when I close a dialog and make sure the div is removed from the DOM.

Now it is deprecated and I am supposed to use
$(document).on("pagecontainerhide", function(){});

but this gets triggerred on every page transition, even before the dialog page is show.
I want to attach a function to the event this "#pageid" gets hidden. How can I do that?

thanks a lot