getIds: ->
@models.map -> it.id or it.get('id') or it.cid
+ url: ->
+ id = @get('id') or @get('slug')
+ if id
+ "#{@urlRoot}/#id.json"
+ else
+ "#{@urlRoot}.json"
+
+
+ load: ->
+ @loadCollection()
+
+ loadCollection: ->
+ @wait()
+ @trigger 'load', this
+ @fetch do
+ success : ~> @unwait(); @trigger 'load-success', this
+ error : ~> @unwait(); @trigger 'load-error', this, ...arguments
+ this
+
### Serialization
@model = @collection or= new GraphList
BaseView::initialize ...
# console.log "#this.initialize!"
+
+ @collection
+ .once 'load-success', @onLoad, this
+ .load()
+
+
+ onLoad: ->
+ console.log "#this.onLoad!"
+ @triggerReady()
+ @isBuilt = false
+ @render()
toTemplateLocals: ->
locals = BaseView::toTemplateLocals ...
{ Graph, GraphList, GraphListView
} = require 'limn/graph'
+root = do -> this
+
# 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) ->
- graphs = new GraphList graph_list_data
- view = new GraphListView { 'collection': graphs }
+ # graphs = root.graphs = new GraphList graph_list_data
+ # view = root.view = new GraphListView { 'collection': graphs }
+ view = root.view = new GraphListView
+ graphs = root.graphs = view.collection
$ '#content .inner' .append view.el
# URL to query for saved graph JSON data.
-graph_list_url = '/graphs.json'
+# graph_list_url = '/graphs.json'
+#
+# jQuery.ajax do
+# url : graph_list_url
+# dataType : 'json'
+# success : (res) ->
+# # result will be the returned JSON
+# # data of all of the saved graphs
+# jQuery main.bind this, res
+# error : (err) -> console.error err
-jQuery.ajax do
- url : graph_list_url
- dataType : 'json'
- success : (res) ->
- # result will be the returned JSON
- # data of all of the saved graphs
- jQuery main.bind this, res
- error : (err) -> console.error err
+jQuery main
\ No newline at end of file