@@ -10,9 +10,9 @@ define([
1010 'views/forms/method' ,
1111 'views/methods/page' ,
1212 'collections/methods' ,
13- 'models/method ' ,
13+ 'models/resource ' ,
1414 'models/notificationtotal'
15- ] , function ( $ , _ , Backbone , Vm , Mustache , Session , resourceListTemplate , ResourceForm , MethodForm , MethodView , Methods , MethodModel , NTotals ) {
15+ ] , function ( $ , _ , Backbone , Vm , Mustache , Session , resourceListTemplate , ResourceForm , MethodForm , MethodView , Methods , ResourceModel , NTotals ) {
1616 var ApisPage = Backbone . View . extend ( {
1717 el : '.method-list-container' ,
1818 initialize : function ( ) {
@@ -59,17 +59,23 @@ define([
5959 render : function ( ) {
6060 var that = this ;
6161 this . methods = new Methods ( ) ;
62- this . resource = new MethodModel ( ) ;
62+
63+ // re-request resource only if necessary
64+ if ( that . options . resource ) {
65+ this . resource = that . options . resource ;
66+ } else {
67+ this . resource = new ResourceModel ( ) ;
68+ this . resource . options = {
69+ username : that . options . username ,
70+ apiname : that . options . apiname ,
71+ version : that . options . version ,
72+ resourceId : that . options . resourceId
73+ } ;
74+ this . resource . fetch ( ) ;
75+ }
6376 that . $el . attr ( 'data-resource-id' , that . options . resourceId ) ;
6477 that . $el . fadeIn ( 200 ) ;
6578
66- this . resource . set ( {
67- username : that . options . username ,
68- apiname : that . options . apiname ,
69- version : that . options . version ,
70- resourceId : that . options . resourceId
71- } ) ;
72- this . resource . fetch ( ) ;
7379 this . methods . username = that . options . username ;
7480 this . methods . apiname = that . options . apiname ;
7581 this . methods . version = that . options . version ;
0 commit comments