DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
  • Legacy
    • can-ejs
    • can-list
    • can-map
      • prototype
        • DEFAULT-ATTR
        • attr
        • bind
        • compute
        • each
        • removeAttr
        • serialize
        • unbind
      • static
        • keys
    • can-map-backup
    • can-map-define
    • can-view-href
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Legacy
  • /
  • can-map
  • /
  • unbind
  • / On this page
    • unbind

      function

      Unbind event handlers from a Map.

      • source

      map.unbind(eventType[, handler])

      Parameters

      1. eventType {String}:

        the type of event to unbind, exactly as passed to bind

      2. handler {function}:

        the handler to unbind

        var map = new Map({ a: 1 });
        
        function log(){
            console.log("val", map.attr("a");
        }
        
        map.bind("change", log);
        
        map.attr("a", 2);
        
        // Bind callback called.
        map.unbind("change", log);
        

      unbind unbinds event handlers previously bound with bind. If no handler is passed, all handlers for the given event type will be unbound.

      var i = 0,
          increaseBy2 = function() { i += 2; },
          increaseBy3 = function() { i += 3; },
          o = new Map();
      
      o.bind('change', increaseBy2);
      o.bind('change', increaseBy3);
      o.attr('a', 'Alice');
      i; // 5
      
      o.unbind('change', increaseBy2);
      o.attr('b', 'Bob');
      i; // 8
      
      o.unbind('change');
      o.attr('e', 'Eve');
      i; // 8
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.