Add _onAfterLeave hook to page views