mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 07:38:20 -05:00
Page:
Access url params in a view
Pages
Access dev database
Access power user features
Access url params in a view
Accessing data through data attribute
Add a Mongoose Model
Add a collection schema
Add a collection
Add a form
Add a route
Add a view
Add basic REST endpoints for a collection
Add events to a view
Add methods for special server endpoints
Add space between elements
Adventurer Home
Aether
Ambassador Home
Archmage Home
Artisan Home
Artisan How To Index
Autocomplete Tuning
Building A Level
Call server from view
Change player level
Chat Room Rules
Chat Room
Chief Artisan Level Audition
Client models
Coco Models
Coding Guidelines for Artisans
Coding Guidelines
Component Authoring Guide
Component
Components And Systems Tabs
Connect Backbone to new collection
Cookbook
Debug a template
Dev Setup: General Information
Dev Setup: Issues
Dev Setup: Linux
Dev Setup: Mac
Dev Setup: Vagrant
Dev Setup: Windows
Developer organization
Diplomat Home
Edit page translations
Editing Thang Components
Educational Standards
Events, subscriptions, shortcuts
File system
Git Policies
Goals
HOWTO: Create static teacher page
Handle a server error
Home
Important Artisan Concepts
Inspect a view
JSON Schema
Keyboard Shortcuts
Level editor
Make yourself admin
Mission statement
Multiplayer
Organize a complicated template
Permissions
Programming Concepts
Project Ideas List
Referee Scripting
Run dev client on prod db
Sample Code
Scribe Home
Scripts Tab
Scripts
Settings Tab
Show data in a view
Simplify Collision
Start a New Level
Surface
System
Tasks Tab
Technical overview
Test client interface
Test client
Test server endpoint
Testing
Thang Component System
Thang
Thangs Tab
Third party software and services
Tome
Translate page strings
Treema
Versioning
Views
World
i18n Glossary es 419
i18n Glossary nb
i18n Glossary ru
i18n
No results
1
Access url params in a view
Scott Erickson edited this page 2015-12-18 14:25:36 -08:00
Problem
You want to access parts of a URL for your view, for example to view a specific document in the db.
Solution
For path parameters, use Backbone Router routes in the url you add to Router.coffee, and access the values in your view's initialize function. For GET parameters, use core/utils.coffee's getQueryVariable
function.
Example
In Router.coffee
routes:
'/doodads/:doodadID': go('DoodadView')
...
DoodadView.coffee
utils = require 'core/utils'
class DoodadView extends RootView
initialize: (options, doodadID) ->
@doodad = new Doodad({_id: doodadID})
@showTab = utils.getQueryVariable('show-tab')
So for example when navigating to the url /doodad/sprocket?show-tab=change-history
, doodadID
will be "sprocket"
and @showTab
will be "change-history"
.
Resources
- Home
- Archmage Home
- Artisan Home
- Adventurer Home
- Scribe Home
- Diplomat Home
- Ambassador 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
- Artisan How-To Index
- Adventurer General
- Scribe General
- Diplomat General
- i18n
- i18n Glossary nb
- i18n Glossary ru
- i18n Glossary es-419
- Ambassador General
- 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
CodeCombat | Home | Blog | Forum | Teachers | Legal | Contribute