Updated the javascript to emit events

* Changed the JS around a bit so it emits events rather than having the user override a single JS function. Should allow for more flexibility on the user's end.
* Switched to using data attributes to carry the ID and properties through.