Skip to content

event delegation w/ selector for elements that do not yet exist #4

@jameslaneconkling

Description

@jameslaneconkling

Having trouble delegating events for elements that might not yet exist. E.g. the below code does not work, unless I bind the 'mouseenter' handler after the graph has already been created.

var GraphView = Backbone.D3View.extend({
  tagName: 'svg',

  initialize: function(){
    this.delegate('mouseenter', '.node', function(e){
      console.log(e);
    });

    this.buildGraph();
  }
};

Or am I misunderstanding the point of event delegation, and/or implementing it incorrectly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions