bigbluebutton-Github/client/bbb-html5-client/public/js/views/app.coffee

43 lines
1.1 KiB
CoffeeScript
Raw Normal View History

define [
'jquery',
'underscore',
'backbone'
], ($, _, Backbone) ->
# Application view
# Used to control the current active view (i.e. the current
# "page" being seen by the user).
AppView = Backbone.View.extend
el: $('#session-container')
initialize: ->
@currentView = null
render: (view) ->
@_closeCurrentView()
@currentView = view
@currentView.render()
# we want html(), so that all events from the old view are also
# removed as well as the html content
@$el.html @currentView.el
@
_closeCurrentView: () ->
@currentView.close() if @currentView?
# Default close() method for all views
# More details at:
# http://lostechies.com/derickbailey/2011/09/15/zombies-run-managing-page-transitions-in-backbone-apps/
Backbone.View.prototype.close = ->
@remove()
@unbind()
# Used to render subviews
# From: http://ianstormtaylor.com/rendering-views-in-backbonejs-isnt-always-simple/
Backbone.View.prototype.assign = (view, selector) ->
view.setElement(@$(selector)).render()
2013-09-24 21:13:09 +08:00
AppView