mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-01 10:43:02 +08:00
34 lines
742 B
CoffeeScript
34 lines
742 B
CoffeeScript
$ ->
|
|
Component = Backbone.Model.extend
|
|
idAttribute: '_id'
|
|
|
|
CompontentCollection = Backbone.Collection.extend
|
|
model: Component
|
|
url: '/component/resource/'
|
|
|
|
ListItemView = Backbone.View.extend
|
|
tagName: 'tr'
|
|
|
|
initialize: ->
|
|
@template = RP.tmpl '#list-item-template'
|
|
|
|
render: ->
|
|
@$el.html @template @model.toJSON()
|
|
return @
|
|
|
|
ListView = Backbone.View.extend
|
|
el: '#list-view'
|
|
|
|
components: new CompontentCollection()
|
|
|
|
initialize: ->
|
|
@components.on 'reset', =>
|
|
@components.each (component) =>
|
|
view = new ListItemView
|
|
model: component
|
|
@$('.table-component tbody').append view.render().el
|
|
|
|
@components.fetch reset: true
|
|
|
|
new ListView()
|