方法和说明 |
on
它将一个事件绑定到一个对象,并在一个事件被触发时执行回调。
|
off
它从对象中删除回调函数或所有事件。
|
trigger
它为给定的事件调用回调函数。
|
一次
它扩展了backbone.Model类,同时创建了你自己的backbone Model。
|
listenTo
它通知一个对象监听另一个对象上的事件。
|
stopListening
它可以用来停止监听其他对象上的事件。
|
listenToOnce
它导致在回调函数被删除之前listenTo只发生一次。
|
事件和描述 |
"add"(model, collection, options)
将模型添加到集合时使用。
|
"remove"(model, collection, options)
它从集合中删除一个模型。
|
"reset"(collection, options)
用于重置集合内容。
|
"sort"(collection, options)
当集合需要重新排序时使用。
|
"change"(model, options)
当要对模型的属性进行更改时使用。
|
"change:[attribute]"(model, value, options)
当属性有更新时使用。
|
"destroy"(model, collection, options)
当模型被销毁时触发。
|
"request"(model_or_collection, xhr, options)
当模型或集合开始向服务器请求时使用。
|
"sync"(model_or_collection, resp, options)
当模型或集合与服务器成功同步时使用。
|
"error"(model_or_collection, resp, options)
当请求服务器出错时激活。
|
"invalid"(model, error, options)
当模型验证失败时,返回invalid。
|
"route:[name]"(params)
当有特定的路由匹配时,可以使用这个事件。
|
"route"(route,params)
当与任何路由匹配时使用。
|
"route"(router, route, params)
当与任何路由匹配时,历史使用它。
|
"all"
它通过传递的事件名称作为第一个参数为所有触发的事件触发。
|