Backbone
所属分类:人工智能/神经网络/深度学习
开发工具:CoffeeScript
文件大小:7KB
下载次数:0
上传日期:2014-03-03 15:40:21
上 传 者:
sh-1993
说明: 主干网事件列表
(Evented lists for Backbone)
文件列表:
GruntFile.coffee (4917, 2014-03-03)
LICENSE (561, 2014-03-03)
backbone.list.js (4122, 2014-03-03)
backbone.list.min.js (2297, 2014-03-03)
package.json (914, 2014-03-03)
src (0, 2014-03-03)
src\backbone.list.coffee (1968, 2014-03-03)
# Backbone.List
Evented lists for Backbone! For when you want the power of a Backbone Collection
(classing and subclassing, events and change subscribing, etc) for lists
of non-models (e.g. strings, views, and more!)
```coffeescript
# Class and subclass lists
class List extends Backbone.List
getActiveItem: ->
for item in @
return item if item.active
# Standard invocation
people = new Backbone.List [ 'john', 'steve', 'mary' ]
# Standart JS Array Methods
people.pop()
people.unshift 'jason'
# Underscore Array Methods
people.find (item) -> item[0] is 'j'
people.sortBy (item) -> item.toLowerCase()
people.contains 'john'
# Event binding
poeple.trigger 'myEvent'
people.on 'myEvent', ->
# Backbone Collection style events
people.on 'add', ->
people.on 'remove', ->
people.on 'reset', ->
# Backbobne.Collection style event bubbling
class ViewManager extends Backbone.List
eventNamespace: false
view.viewManager = new ViewManager
view.viewManager.add subView
subView.trigger 'rendered' # => This will trigger 'rendered' on view.viewManager
```
Documentation coming soon...
近期下载者:
相关文件:
收藏者: