2013-05-24 11 views
0

내 프로젝트 중 하나에서 'd3.dispatch'기능을 사용하려고합니다. 사용자 지정 이벤트를 설정하고 네임 스페이스를 사용하여 사용 가능한 청취자에게 보냅니다. 네임 스페이스가있는 사용자 정의 이벤트 전달

내가이 짓 :

 
var dispatcher = d3.dispatch("period_selected"); 

brush.on("brush", function() { 
    var s = brush.extent() 

    // patch the event to listeners 
    dispatcher.period_selected(s); 

}); 

// register listener for the event namespaced 
dispatcher.on("period_selected.my_namespace", function(s,f) { 

    console.log(event.period_selected); 
}); 

을하지만 결과로와 네임 스페이스를 다시 얻을 수 없습니다. 너는 어떤 생각을 가지고 있니? 사전

답변

1

네임 스페이스에

덕분에 인수로 전달이나 이벤트에 할당되지 않습니다. ...

dispatch.period_selected(s, "my_namespace")

를 여기에 사용할 수 것이다 : 네임 스페이스처럼 정말을 을 거라고 경우에, 당신은 매개 변수로 함께 그것을 통과해야

dispatcher.on("period_selected.namespace", function(s, namespace) { 
    // Use namespace here 
}); 
관련 문제