Created
May 8, 2012 12:28
-
-
Save Sephi-Chan/2634577 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Views.ProfileSummary extends Backbone.View | |
template: JST['side_bar/profile_summary'] | |
events: | |
'click .favorites' : 'goToFavorites' | |
render: -> | |
html = @template | |
currentUser: Store.get('currentUser') | |
$(@el).html(html) | |
@ | |
goToFavorites: -> | |
MyApp.layout.content.show(new Pages.Favorites) | |
false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Views.SideBar extends Backbone.View | |
initialize: -> | |
Store.on('change:currentUser', @render, @) | |
@profileSummary = new Views.ProfileSummary | |
@vehiclesList = new Views.VehiclesList | |
render: -> | |
$(@el) | |
.empty() | |
.append(@profileSummary.render().el) | |
.append(@vehiclesList.render().el) | |
@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Views.VehiclesList extends Backbone.View | |
template: JST['side_bar/vehicles_list'] | |
id: 'vehicles-list' | |
events: | |
'click .add-vehicle' : 'addVehicle' | |
initialize: -> | |
currentUser = Store.get('currentUser') | |
currentUser.get('vehicles').on('add remove', @render, @) | |
render: -> | |
currentUser = Store.get('currentUser') | |
html = $(@template(currentUser: currentUser)) | |
@el = $(@el).html(html) | |
$items = $() | |
currentUser.get('vehicles').each (vehicle)-> | |
subView = new Views.VehiclesListItem(model: vehicle) | |
$item = $(subView.render().el) | |
$items = $items.add($item) | |
@$('.items').replaceWith($items) | |
@ | |
addVehicle: -> | |
Backbone.history.navigate('/vehicles/new') | |
MyApp.layout.content.show(new Pages.NewVehicle) | |
false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment