Add error handling to `on` method to prevent wrong function calls

People might leave out the second param as they might be familiar
with jQuery's `on` method.