Module-documentation

version 1.0.0
module: event-dom
maintanance: Marco Asbreuk
home
all modules

Preventing DOM-events

Events can be prevented by using a before-subscriber. Normally you would have logic here to determine whether or not preventDefault: this example preventDefaults always.

Click on the button: no alert will come.

Code-example:

<body>
    <button id="buttongo" class="pure-button pure-button-primary pure-button-bordered">Click me</button>
</body>
<script src="itsabuild-min.js"></script>
<script>
    var afterClick = function(e) {
        // the alert will never pop-up
        alert('Button #buttongo is clicked');
    };
    var beforeClick = function(e) {
        e.preventDefault();
    };

    ITSA.Event.before('tap', beforeClick, '#buttongo');
    ITSA.Event.after('tap', afterClick, '#buttongo');
</script>
API Docs