Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有多个集合绑定到同一个回调。我需要一种方法来识别实际发生事件的集合。但是,我无法将参数传递给backbone.js 中的回调。有出路吗?
在 Backbone 集合中,事件处理程序this始终设置为触发事件的集合:
this
function eventHandler(){ console.log(this); // this refers to either collection1 or collection2, depending on where the event was triggered }; collection1.on("sth", eventHandler); collection2.on("sth", eventHandler);