Skip to content

Commit b240a2b

Browse files
author
Emmanouil Konstantinidis
committed
Hide data fields if GET or OPTIONS
1 parent c35e3df commit b240a2b

File tree

2 files changed

+16
-1
lines changed
  • rest_framework_docs

2 files changed

+16
-1
lines changed

rest_framework_docs/static/rest_framework_docs/js/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ $( document ).ready(function() {
137137
$("#methods .method").removeClass( 'active' );
138138
// Add 'active' to the clicked button
139139
$(this).addClass( 'active' );
140+
_toggleFields();
140141
});
141142
};
142143

@@ -152,7 +153,21 @@ $( document ).ready(function() {
152153
}
153154
};
154155

156+
var _toggleFields = function () {
157+
// Show/Hide Data depending on method type
158+
var method = $("#methods").find( ".active" ).text();
159+
if (method === 'GET' || method === 'OPTIONS') {
160+
$('#headerData').hide();
161+
$('#fields').hide();
162+
} else {
163+
$('#headerData').show();
164+
$('#fields').show();
165+
}
166+
};
167+
155168
var _setupFields = function (fields) {
169+
_toggleFields();
170+
156171
$.each( fields, function( i, field ) {
157172
var label = field.name.replace('_', ' ');
158173
$('#fields').append("" +

rest_framework_docs/templates/rest_framework_docs/home.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ <h5 class="section-title"><span>Headers</span></h5>
121121
</div>
122122
</div>
123123

124-
<h5 class="section-title"><span>Data</span></h5>
124+
<h5 class="section-title" id="headerData"><span>Data</span></h5>
125125
<div id="fields" class="fields"></div>
126126

127127
<button type="submit" class="btn btn-default">Send</button>

0 commit comments

Comments
 (0)