-
Notifications
You must be signed in to change notification settings - Fork 3
Options
-
name- convenience name string for debugging - will be available on the view instance -
appendTo- if set andelis not set then the view will be appended to this eleeent.appendTocan be a sizzle selector, a DOM element, or a jQuery object -
bindings- declarative syntax to setup view listeners- array of arrays
- each sub array contains: what to listen to, the event, and the callback
-
view context is assumed
bindings : [ ['model', 'change:price', 'showNewPrice'], ['model', 'change:discount', 'animateAdvertisement'] ],
-
-
defaultOptions- the options to be used as the default. Passed in options will extend this. -
ModelType- if supplied,this.modelwill be of typeModelType- default isMasseuseModel -
modelData- if supplied,this.modelwill be initialized with,this.model.set(modelData)- ViewContext - Convenience helper to acces the view context from within modelData
-
this helps in separating view options and view definitions into separate AMDs
modelData : { viewId : ViewContext('cid') }
-
- ViewContext - Convenience helper to acces the view context from within modelData
-
template- String to be used as the umderscore template -
viewOptions- list of keys for which each key value pair fromoptionswill be transferred to the view instancevar view = new BaseView({ name : 'MyName', appendView : false, ModelType : MyCustomModel, modelData : { ... }, bindings : [ ['model', 'change:price', 'showNewPrice'], ['model', 'change:discount', 'animateAdvertisement'] ], templateHtml : '<div><%= price %> : <%= discount %></div>', // Underscore templating that will - if provided - be turned into this.template using _.template(templateHtml) });