Skip to content

Instantly share code, notes, and snippets.

@jeffAwesome
Last active August 29, 2015 13:56
Show Gist options
  • Save jeffAwesome/8996887 to your computer and use it in GitHub Desktop.
Save jeffAwesome/8996887 to your computer and use it in GitHub Desktop.
# this is the show.controller file
@Arc.module "MapApp.Show", (Show, App, Backbone, Marionette, $, _) ->
# the show controller method is public so we can access it
Show.Controller =
init: () ->
@getZones()
showMap: (map_view)->
App.mainRegion.show map_view
equalize()
getZones: () ->
$.getJSON "locations/2/geometries.json", (data) ->
# were calling the create map method here and passing in the returned data
Show.Controller.createMap(data)
createMap: (data) ->
# here were assigning the data to the attributes argument in the model.
my_map = new App.Entities.Map(data)
map_view = new Show.Map
model: my_map
@showMap(map_view)
# in the show view you can reference zones as
zones = this.model.zones
# And of course the backbone Model
@Arc.module "Entities", (Entities, App, Backbone, Marionette, $, _) ->
class Entities.Map extends Entities.Model
initialize: (attributes)->
@zones = attributes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment