Skip to content

Commit

Permalink
GET and POST areas toggle each other, refs #1871
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Nov 13, 2022
1 parent 51d60d7 commit ca66ea5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions datasette/templates/api_explorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ <h2>API response: HTTP <span id="response-status"></span></h2>
var output = document.getElementById('output');
var errorList = output.querySelector('.errors');

// Cause GET and POST regions to toggle each other
var getDetails = getForm.closest('details');
var postDetails = postForm.closest('details');
getDetails.addEventListener('toggle', (ev) => {
if (getDetails.open) {
postDetails.open = false;
}
});
postDetails.addEventListener('toggle', (ev) => {
if (postDetails.open) {
getDetails.open = false;
}
});

getForm.addEventListener("submit", (ev) => {
ev.preventDefault();
var formData = new FormData(getForm);
Expand Down

0 comments on commit ca66ea5

Please sign in to comment.