我的 Backbone 应用程序中有以下代码,有没有办法将“this”绑定到回调,而不必一直分配“$this”?
addItem: function()
{
var $this = this;
(new Project()).save({name:$('#project_name').val()},{
success:function(model, response)
{
$this.collection.add(model);
},
error: function()
{
console.log('wtf');
}
});
}