Pass router to all views

This commit is contained in:
Mohsen Azimi
2015-03-16 11:08:28 -07:00
parent 194f2d5fb5
commit 9ed1ad88ec
6 changed files with 32 additions and 12 deletions

View File

@@ -10,6 +10,9 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
initialize: function(opts){
opts = opts || {};
this.router = opts.router;
// set up the UI for input
this.model.auths = [];
var key, value;
@@ -50,12 +53,12 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
var button;
if (auth.type === 'apiKey' && $('#apikey_button').length === 0) {
button = new SwaggerUi.Views.ApiKeyButton({model: auth}).render().el;
button = new SwaggerUi.Views.ApiKeyButton({model: auth, router: this.router}).render().el;
$('.auth_main_container').append(button);
}
if (auth.type === 'basicAuth' && $('#basic_auth_button').length === 0) {
button = new SwaggerUi.Views.BasicAuthButton({model: auth}).render().el;
button = new SwaggerUi.Views.BasicAuthButton({model: auth, router: this.router}).render().el;
$('.auth_main_container').append(button);
}
}
@@ -93,6 +96,7 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
resource.id = resource.id.replace(/\s/g, '_');
var resourceView = new SwaggerUi.Views.ResourceView({
model: resource,
router: this.router,
tagName: 'li',
id: 'resource_' + resource.id,
className: 'resource',