/**
* @class View for a showing a list of all saved graphs
*/
-GraphIndexView = exports.GraphIndexView = BaseView.extend do # {{{
+GraphListView = exports.GraphListView = BaseView.extend do # {{{
__bind__ : <[
render
]>
__debounce__: <[ render ]>
tagName : 'section'
- className : 'graph-index-view'
- template : require 'kraken/template/graph-index'
+ className : 'graph-list-view'
+ template : require 'kraken/template/graph-list'
data : {}
ready : false
-
- initialize : (o={}) ->
- @model = new GraphList (o['graph_list_data'])
+
+ initialize : ->
+ @model = @collection or= new GraphList
BaseView::initialize ...
console.log "#this.initialize!"
+
+ toTemplateLocals: ->
+ locals = BaseView::toTemplateLocals ...
+ locals.collection = @collection
+ locals
+
\ No newline at end of file
-models = require 'kraken/graph/graph-model'
-display_views = require 'kraken/graph/graph-display-view'
-edit_views = require 'kraken/graph/graph-edit-view'
-index_views = require 'kraken/graph/graph-index-view'
+models = require 'kraken/graph/graph-model'
+display_views = require 'kraken/graph/graph-display-view'
+edit_views = require 'kraken/graph/graph-edit-view'
+index_views = require 'kraken/graph/graph-list-view'
exports import models import display_views import edit_views import index_views
} = require 'kraken/util'
{ BaseView, BaseModel, BaseList,
} = require 'kraken/base'
-{ Graph, GraphList, GraphIndexView
+{ Graph, GraphList, GraphListView
} = require 'kraken/graph'
-root = this
-
-# instantiates a new GraphIndexView with the
+# instantiates a new GraphListView with the
# passed in JSON graph_list_data, and then
# appends the rendered view to the DOM.
main = (graph_list_data) ->
- view = new GraphIndexView { 'graph_list_data': graph_list_data }
+ graphs = new GraphList graph_list_data
+ view = new GraphListView { 'collection': graphs }
$ '#content .inner' .append view.el
# URL to query for saved graph JSON data.
-graph_list_url = 'http://localhost:8081/graphslist'
+graph_list_url = '/graphslist'
jQuery.ajax do
- url : 'http://localhost:8081/graphslist'
+ url : graph_list_url
dataType : 'json'
success : (res) ->
- console.log("got %o", res)
# result will be the returned JSON
# data of all of the saved graphs
- jQuery main res
+ jQuery main.bind this, res
error : (err) -> console.error err