public
Created

  • Download Gist
gistfile1.coffee
CoffeeScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
define [
'jquery',
'underscore',
'backbone',
'cs!models/session',
'cs!views/notice',
'cs!views/header',
'cs!views/main_menu',
'cs!views/hotel/hotel',
'cs!views/rooms/rooms',
'cs!views/assets/assets',
'hbs!template/layout'
], ( $, _, Backbone
, Session
, NoticeView
, HeaderView
, MainMenuView
, HotelView
, RoomsView
, AssetsView
, LayoutTemplate ) ->
return Backbone.View.extend
el: $("#main-container")
template: LayoutTemplate
 
initialize: ->
_.bindAll @, 'render', 'hotel', 'rooms'
Session.on('change:auth', (session) ->
console.log ' session has changed '
console.log session
@render()
)
 
events:
'click a.hotel' : 'hotel'
'click a.room' : 'rooms'
'click a.assets' : 'assets'
 
render: ->
if Session.getAuth()
@$el.html @template()
@$('#header').html new HeaderView().render().el
@$('#menu').html new MainMenuView().render().el
@hotel()
else
Backbone.history.navigate 'login', trigger: true
@
 
hotel: (e) ->
if e is not undefined
e.preventDefault()
@$('#content').html new HotelView().render().el
 
rooms: (e) ->
e.preventDefault()
@$('#content').html new RoomsView().render().el
 
assets: (e) ->
e.preventDefault()
@$('#content').html new AssetsView().render().el

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.