有没有更短更优雅的方式来保持 BackboneJS 视图中的上下文?
this.$el.find(this.itemViewContainer).sortable("destroy").sortable({
connectWith:'.tasks',
delay:140,
revert:200,
items:'li:not(.locked)',
placeholder:'ui-state-highlight',
start:_.bind(function (event, ui){this._sortStart(event, ui);}, this),
receive:_.bind(function (event, ui){this._sortReceive(event, ui);}, this),
stop:_.bind(function (event, ui){this._sortStop(event, ui);}, this)
});
我指的是:
- 开始事件
- 甚至收到
- 停止事件
重要的是:this、event 和 ui 将被传递给内部视图事件。