Skip to content

Instantly share code, notes, and snippets.

@davidvanleeuwen
Created April 4, 2013 09:50
Show Gist options
  • Save davidvanleeuwen/5309171 to your computer and use it in GitHub Desktop.
Save davidvanleeuwen/5309171 to your computer and use it in GitHub Desktop.
unless Backbone?
throw new Error("Backbone is not defined. Please include
the latest version from http://documentcloud.github.com/backbone/backbone.js")
class Backbone.Modal extends Backbone.View
constructor: ->
args = Array.prototype.slice.apply(arguments)
Backbone.View.prototype.constructor.apply(this, args)
render: ->
@setUIElements()
@delegateModalEvents()
return this
setUIElements: ->
template = @getOption('template')
@views = @getOption('views')
@viewContainer = @getOption('viewContainer')
if _.isUndefined(@template) and _.isUndefined(@views)
throw new Error('No template or views defined for Backbone.Modal')
if @template and @views and _.isUndefined(@viewContainer)
throw new Error('No viewContainer defined for Backbone.Modal')
getOption: (option) ->
return unless option
if @options and option in @options and @options[option]?
return @options[option]
else
return @[option]
delegateModalEvents: ->
cancelEl = @getOption('cancelEl')
submitEl = @getOption('submitEl')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment