mateusmaso / hipbone

Backbone based framework for building SPAs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

View get/set and defaults for options

mateusmaso opened this issue · comments

Same behavior of model attributes and collection meta for view options.

The last commit introduces this new feature. By default, any changes via get/set will update bindings and the options are also passed in context:

class App.YoutubeView extends Hipbone.View

  ...

  defaults:
    playing: false

  play: ->
    @set(playing: true)

  stop: ->
    @set(playing: false)

  alertState: ->
    alert(@get("playing"))

your template:

{{#if playing bind=true keypath="playing"}}
  <h1>Playing video</h1>
{{else}}
  <h1>Video stopped</h1>
{{/if}}

...