backbone collection add 事件回调参数
this.listenTo(this.collection, 'add', this.renderBook); renderBook: function (item) {
var bookView = new app.BookView({
model: item
});
this.$el.append(bookView.render().el);
}
当我们给collection添加一个model的时候,如果绑定了collection的add事件,那么该事件的回调函数会接收三个参数。
第一个参数是:当前被add到collection的model对象;
第二个参数是:当前collection对象。
第三个参数是可选项,具体是什么官方也没有介绍。
其它的事件回调类似。以下附上官方事件列表。
- "add" (model, collection, options) — when a model is added to a collection.
- "remove" (model, collection, options) — when a model is removed from a collection.
- "reset" (collection, options) — when the collection's entire contents have been replaced.
- "sort" (collection, options) — when the collection has been re-sorted.
- "change" (model, options) — when a model's attributes have changed.
- "change:[attribute]" (model, value, options) — when a specific attribute has been updated.
- "destroy" (model, collection, options) — when a model is destroyed.
- "request" (model, xhr, options) — when a model (or collection) has started a request to the server.
- "sync" (model, resp, options) — when a model (or collection) has been successfully synced with the server.
- "error" (model, xhr, options) — when a model's save call fails on the server.
- "invalid" (model, error, options) — when a model's validation fails on the client.
- "route:[name]" (params) — Fired by the router when a specific route is matched.
- "route" (router, route, params) — Fired by history (or router) when any route has been matched.
- "all" — this special event fires for any triggered event, passing the event name as the first argument.
backbone collection add 事件回调参数的更多相关文章
- 回发或回调参数无效。在配置中使用 pages enableEventValidation=true 或在页面中使用 %@ Page EnableEventValidation=true % 启用了事件验证
WebForm中回发或回调参数无效问题的解决 解决 .NET中回发或回调参数无效问题的解 该错误的详细提示信息为: 回发或回调参数无效.在配置中使用 <pages enableEventVali ...
- 回发或回调参数无效。在配置中使用 <pages enableEventValidation="true"/> 或在页面中使用 <%@ Page EnableEventValidation="true" %> 启用了事件验证。
问题补充: “/Source”应用程序中的服务器错误. 回发或回调参数无效.在配置中使用 <pages enableEventValidation="true"/> 或 ...
- backbone.Collection源码笔记
Backbone.Collection backbone的Collection(集合),用来存储多个model,并且可以多这些model进行数组一样的操作,比如添加,修改,删除,排序,插入,根据索引取 ...
- Backbone Collection——数据模型集合
如果将一个Model对象比喻成数据库中的一条记录,那么Collection就是一张数据表.它表示为一个模型集合类,用于存储和管理一系列相同类型的模型对象. 1.创建集合集合用于组织和管理多个模型,但它 ...
- Backbone Collection 源码简谈
一切由一个例子引发: var Man=Backbone.Model.extend({ initilize:function(){ this.bind('change:name',function(){ ...
- 用block做事件回调来简化代码,提高开发效率
我们在自定义view的时候,通常要考虑view的封装复用,所以如何把view的事件回调给Controller就是个需要好好考虑的问题, 一般来说,可选的方式主要有target-action和de ...
- asp.net 解决 "回发或回调参数无效" 一些常见解决方案
一.回发或回调参数无效,出现下图错误, 常见解决方案: 1.在页面的<%@ Page Language="C#" AutoEventWireup="true&qu ...
- asp.net 回发或回调参数无效的各种情况分析及解决办法
昨天,在实现级联菜单的时候,突然出现一下错误: 回发或回调参数无效.在配置中使用 <pages enableEventValidation="true"/> 或在页面中 ...
- 如何对Backbone.Collection进行过滤操作
首先我想说的是这篇文章的题目起的很怪,因为我不知道起个什么名字比较好.渲染列表是我们应用中最常见的操作了吧,在运用Backbone的应用中,我们一般会把列表作为一个Collcetion,然后指定一个V ...
随机推荐
- 使用Spring Security实现权限管理
使用Spring Security实现权限管理 1.技术目标 了解并创建Security框架所需数据表 为项目添加Spring Security框架 掌握Security框架配置 应用Security ...
- Spring学习总结三——SpringIOC容器三
一:spring容器自动装配注入 为了减少xml中配置内容,可以使用自动装配注入,代替setter注入,只需要在 bean对象配置中添加属性autoWire即可,那么在类中就会自动扫描setXXX() ...
- CF Soldier and Badges (贪心)
Soldier and Badges time limit per test 3 seconds memory limit per test 256 megabytes input standard ...
- QTREE3 spoj 2798. Query on a tree again! 树链剖分+线段树
Query on a tree again! 给出一棵树,树节点的颜色初始时为白色,有两种操作: 0.把节点x的颜色置反(黑变白,白变黑). 1.询问节点1到节点x的路径上第一个黑色节点的编号. 分析 ...
- Oracl用代码建标
建标还可以通过编写代码的方式实现,这样在建许多类似的表的时候可以极高建表的效率. create table SCORE --建立表名( ...
- C#导出数据至excel模板
开源分享最近一个客户要做一个将数据直接输出到指定格式的Excel模板中,略施小计,搞定 其中包含了对Excel的增行和删行,打印预览,表头,表体,表尾的控制 using System; using S ...
- AJAX之JSON
AJAX=Asynchronous JavaScript and XML(异步的JavaScript 和XML). AJAX不是新的编程语言,而是一种是用现代标准的新方法,用于创建快速动态网页的技术. ...
- php删除数组中相同的元素,只保留一个相同元素
<?php// 删除数组中相同元素,只保留一个相同元素function formatArray($array){sort($array);$tem = ”;$temarray = array() ...
- iOS 触摸的位置放一个大头针
iOS 触摸的位置放一个大头针 UITapGestureRecognizer *mTap = [[UITapGestureRecognizer alloc] initWithTarget:self a ...
- AMQ学习笔记 - 06. 可靠消息传送
概述 本文介绍JMS中可能发生消息故障的3个隐患阶段,以及确保消息安全的3种保障机制. 故障分析 在介绍可靠传送的确保机制之前,先分析消息在传送的过程中可能在哪个阶段出现问题. 1.两个跃点 跃点的含 ...