By passing parent view as an option to child views, child views can access parent views and eventually can access model of MainView There is alos a new domEl option available for SwaggerUI constructor. User can send domEl instead of dom_id to specifiy which element they want to render to
26 lines
813 B
CoffeeScript
26 lines
813 B
CoffeeScript
class StatusCodeView extends Backbone.View
|
|
initialize: ->
|
|
|
|
render: ->
|
|
template = @template()
|
|
$(@el).html(template(@model))
|
|
|
|
models = this.options.parent.options.parent.options.parent.model.models
|
|
|
|
if models.hasOwnProperty @model.responseModel
|
|
models = this.options.parent.options.parent.options.parent.model.models
|
|
responseModel =
|
|
sampleJSON: JSON.stringify(models[@model.responseModel].createJSONSample(), null, 2)
|
|
isParam: false
|
|
signature: models[@model.responseModel].getMockSignature()
|
|
|
|
responseModelView = new SignatureView({model: responseModel, tagName: 'div'})
|
|
$('.model-signature', @$el).append responseModelView.render().el
|
|
else
|
|
$('.model-signature', @$el).html ''
|
|
@
|
|
|
|
template: ->
|
|
Handlebars.templates.status_code
|
|
|