added support for providing the dom element in stead of just the id