44 lines
816 B
CoffeeScript
44 lines
816 B
CoffeeScript
|
#= require ../shared/form_view
|
||
|
#= require ../sites/domains_view
|
||
|
|
||
|
Locomotive.Views.Sites ||= {}
|
||
|
|
||
|
class Locomotive.Views.Sites.NewView extends Locomotive.Views.Shared.FormView
|
||
|
|
||
|
el: '#content'
|
||
|
|
||
|
events:
|
||
|
'submit': 'save'
|
||
|
|
||
|
initialize: ->
|
||
|
@model = new Locomotive.Models.Site()
|
||
|
|
||
|
Backbone.ModelBinding.bind @
|
||
|
|
||
|
window.foo = @model
|
||
|
|
||
|
render: ->
|
||
|
super()
|
||
|
|
||
|
@render_domains()
|
||
|
|
||
|
render_domains: ->
|
||
|
@domains_view = new Locomotive.Views.Sites.DomainsView model: @model, errors: @options.errors
|
||
|
|
||
|
@$('#site_domains_input label').after(@domains_view.render().el)
|
||
|
|
||
|
save: (event) ->
|
||
|
@save_in_ajax(event)
|
||
|
|
||
|
show_error: (attribute, message, html) ->
|
||
|
if attribute == 'domains'
|
||
|
@domains_view.show_error(message)
|
||
|
else
|
||
|
super
|
||
|
|
||
|
remove: ->
|
||
|
@domains_view.remove()
|
||
|
super
|
||
|
|
||
|
|