How do you remove a handler using a d3.js selector

Found out that although .off() is not supported for d3 v2.9.1, an alternative is
.on('click',null)

Fully:

add_listeners = function() {
    // Remove handler before adding, to avoid superfluous handlers on elements.
    d3.selectAll(".nodes").on('click',null);

    d3.selectAll(".nodes").on("click", function() { 
        //Event handler 
    });
}

Reference:

https://github.com/d3/d3-selection#selection_on

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)