headkit
headkit

Reputation: 3327

How to prevent multiple event listeners on single object?

I need to check if there is an event listener on an $object in jQuery mobile. is there a way that works?

Upvotes: 0

Views: 1371

Answers (2)

Tom G
Tom G

Reputation: 3650

<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"  type="text/javascript"></script>
<script>
    $(function() {
        $("#textDiv").click(function() {
            //Event Handling
        });
        var events = $._data(document.getElementById('textDiv'), "events");
        var eventBound = false;
        if(events != null) {
            var eventBound = true;
        }
    });
</script>
</head>
<body>
<div id="textDiv">Text</div>
</body>
</html>

Upvotes: 1

headkit
headkit

Reputation: 3327

what worked for me was adding events with only using ON and then using the OFF() method to remove all events when leaving the app-state.

Upvotes: 1

Related Questions