Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 20550b5545
Fetching contributors…

Cannot retrieve contributors at this time

file 43 lines (37 sloc) 1.035 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
<html>
  <head>
    <title>Event</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <ul>
      <li><a href="#">One</a></li>
      <li><a href="#">Two</a></li>
      <li><a href="#">Three</a></li>
    </ul>

    <ul id="list-two">
      <li><a href="#">One</a></li>
    </ul>

    <button>Button</button>

    <script src="../build/build.js"></script>

    <script>
      var delegate = require('delegate');
      var uls = document.querySelectorAll('ul');
      var n = 0;

      var fn = delegate.bind(uls[0], 'li a', 'click', function(e){
        console.log(e.target);
        if (++n >= 3) {
          console.log('unbind');
          delegate.unbind(uls[0], 'click', fn, false);
        }
      }, false);

      var fn2 = delegate.bind(uls[1], 'li a', 'click', function(e){
        console.log(e.target);
        if (++n >= 8) {
          console.log('unbind');
          delegate.unbind(uls[1], 'click', fn2, false);
        }
      }, false);
    </script>
  </body>
</html>
Something went wrong with that request. Please try again.