Skip to content

Instantly share code, notes, and snippets.

@paul
Forked from wycats/container_view.coffee
Created February 28, 2012 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paul/1930141 to your computer and use it in GitHub Desktop.
Save paul/1930141 to your computer and use it in GitHub Desktop.
Viz.WidgetsController = Ember.ArrayController.extend
init: ->
@refresh()
setInterval (=> @refresh()), 5000
refresh: ->
$.ajax
url: @get('src'),
type: "GET",
context: this,
success: this.loadData
loadData: (visualizer) ->
@set 'template', Ember.Handlebars.compile(visualizer.template)
@set 'content', visualizer.widgets
Viz.Widgets = Ember.CollectionView.extend
init: ->
@_super()
@set 'content', Viz.WidgetsController.create(src: @get('src'))
createChildView: (viewClass, attributes) ->
attributes.template = @getPath('content.template')
attributes.templateContext = attributes.content
@_super(viewClass, attributes)
# <h1>Surrounding HTML</h1>
# <div>{{view Viz.Widgets src="/visualizers/hosts"}}</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment