jQuery: The Write Less, Do More JavaScript Library

Changeset 4601

Show
Ignore:
Timestamp:
02/03/08 04:33:11 (6 months ago)
Author:
jeresig
Message:

Added support for .unbind(".test") to unbind all namespaced events on an element.

Location:
trunk/jquery
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/src/event.js

    r4600 r4601  
    110110        if ( events ) { 
    111111            // Unbind all events for the element 
    112             if ( types == undefined ) 
     112            if ( types == undefined || types[0] == "." ) 
    113113                for ( var type in events ) 
    114                     this.remove( elem, type ); 
     114                    this.remove( elem, type + (types || "") ); 
    115115            else { 
    116116                // types is actually an event object here 
  • trunk/jquery/test/unit/event.js

    r4436 r4601  
    7373    expect(6); 
    7474 
     75    $("#firstp").bind("custom.test",function(e){ 
     76        ok(true, "Custom event triggered"); 
     77    }); 
     78 
    7579    $("#firstp").bind("click",function(e){ 
    7680        ok(true, "Normal click triggered"); 
     
    9296    // Trigger the remaining fn (1) 
    9397    $("#firstp").trigger("click"); 
     98 
     99    // Remove the remaining fn 
     100    $("#firstp").unbind(".test"); 
     101 
     102    // Trigger the remaining fn (0) 
     103    $("#firstp").trigger("custom"); 
    94104 
    95105    // using contents will get comments regular, text, and comment nodes