only attach handler when showing