Implementation of conditional onEvent helper.

Implementation of a conditional onEvent helper that guards the execution of the event with an alert dialog.