-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Access url params in a view
Scott Erickson edited this page Dec 18, 2015
·
1 revision
You want to access parts of a URL for your view, for example to view a specific document in the db.
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.
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"
.
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