Making attach function idempotent and cursor type configurable

Calling the "attach" function multiple times will bind multiple event listeners. And cursor specified in the "options" parameter is ignored. This patch should fix this. : )