Skip to content
This repository was archived by the owner on Jan 16, 2020. It is now read-only.

Event handlers called multiple times when used on nested elements #14

Open
AdamDz opened this issue Jun 11, 2013 · 0 comments
Open

Event handlers called multiple times when used on nested elements #14

AdamDz opened this issue Jun 11, 2013 · 0 comments

Comments

@AdamDz
Copy link

AdamDz commented Jun 11, 2013

Pointer events triggered by nested elements bubble up. If there is another handler bound higher in DOM, a duplicate pointer event is triggered.

A minimal example:

<html>
<body>
    <div id="outer" style="border: 1px solid red; padding: 50px;">
        <div id="inner" style="border: 1px solid blue; padding: 50px;">
            Click me
        </div>
    </div>
    <script type="text/javascript" src="/static/www/js/lib/jquery.js"></script>
    <script type="text/javascript" src="/static/www/js/lib/pointer.js"></script>
    <script>
        $("#outer").on('pointerdown', function() {
            console.log('outer pointerdown');
        });

        $("#inner").on('pointerdown', function() {
            console.log('inner pointerdown');
        });
    </script>
</body>
</html>

A single click on the inner rectangle produces output:

inner pointerdown
outer pointerdown
inner pointerdown
outer pointerdown
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant