Skip to content

Instantly share code, notes, and snippets.

@thehydroimpulse
Created August 20, 2012 11:57

Revisions

  1. @timgremore timgremore created this gist Jan 3, 2012.
    9 changes: 9 additions & 0 deletions index.html.haml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    - title "#{@game.name}"
    %h1= yield(:title)
    #documents
    = form_tag(assessment_game_documents_path(@game)) do
    %ul
    %script{ type: "text/x-handlebars" }
    {{#collection Game.DocumentsCollectionView contentBinding="Game.documentsController"}}
    %li {{content.name}}
    {{/collection}}
    30 changes: 30 additions & 0 deletions main.js.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    window.Game ||= Ember.Application.create
    ready: () ->
    setInterval(() ->
    Game.documentsController.refresh()
    , 10000)
    this._super()

    Game.Document = Ember.Object.extend
    name: null,
    description: null

    Game.documentsController = Ember.ArrayController.create
    content: [],
    createDocument: (name, description) ->
    document = Game.Document.create
    name: name,
    description: description
    this.pushObject(document)
    refresh: () ->
    $.getJSON("index.json", (data) ->
    for item in data
    Game.documentsController.createDocument item["document"]["name"], item["document"]["description"]
    )

    Game.DocumentsCollectionView = Ember.CollectionView.extend
    itemView: Ember.View.extend
    mouseDown: (evt) ->
    alert "You clicked on " + this.get('content')

    Game.documentsController.refresh()