-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Show data in a view
Scott Erickson edited this page May 19, 2016
·
2 revisions
You want to display data loaded in your view in the view's template.
Access any properties in the template's view with the view
property.
As long as the view subclasses CocoView or one of its subclasses (RootView, ModalView, etc), the template is rendered with a common context. This context always includes a view
property, which provides access to, for example, models and collections loaded by the view.
FooView.coffee
RootView = require 'views/core/RootView'
Foos = require 'collections/Foos'
utils = require 'core/utils'
class FoosView extends RootView
template: require 'templates/foos-view'
initialize: (options, doodadID) ->
@foos = new Foos()
@supermodel.trackRequest(@foos.fetchForDoodad(doodadID))
foos-view.jade
extends /templates/base
block content
h1 All the Foos
ul
for foo in view.foos.models
li= foo.get('name')
h1 Foos Where Bar Is True
ul
for foo in view.foos.where({bar: true})
li= foo.get('name')
CodeCombat | Home | Blog | Forum | Teachers | Legal | Contribute
- Home
- Archmage Home
- Artisan Home
- Diplomat Home
- Archmage General
- Mission statement
- Coco Models
- Coding Guidelines
- Cookbook
- File system
- JSON Schema
- Technical overview
- Testing
- Third party software and services
- Artisan General
- Building A Level
- Coding Guidelines for Artisans
- Editing Thang Components
- Important Artisan Concepts
- Keyboard Shortcuts
- Debugging
- Artisan How-To Index
- Diplomat General
- i18n
- i18n Glossary nb
- i18n Glossary ru
- i18n Glossary es-419
- Dev Setup
- Dev Setup: Linux
- Dev Setup: Windows
- Dev Setup: Mac
- Dev Setup: Vagrant
- Dev Setup: Issues
- Game Engine
- Component
- Multiplayer
- Surface
- System
- Thang
- Thang Component System
- Tome
- World
- Artisan Tabs
- Components And Systems
- Scripts
- Settings
- Thangs
- Other
- Aether
- Client models
- Developer organization
- Educational Standards
- Events, subscriptions, shortcuts
- Chat Room
- Chat Room Rules
- Permissions
- Project Ideas List
- Treema
- Versioning
- Views