Update directives.js

Changed .remove() to .detach() for closePopup. This will allow the popup to retain it's event bindings.