Skip to content

Commit

Permalink
submit buttons now submit type, event handler now on form submit event
Browse files Browse the repository at this point in the history
This should fix #213 as "Enter" triggers a submit and our JavaScript
form code now executes on-sumbit with a prevention of the default post
behavior.
  • Loading branch information
hhund committed Jul 8, 2024
1 parent 777feb6 commit 65d52f6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions dsf-fhir/dsf-fhir-server/src/main/resources/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ window.addEventListener('DOMContentLoaded', () => {
})

// complete questionnaire response
document.querySelector('form > fieldset#form-fieldset > div.row-submit > button#complete-questionnaire-response')?.addEventListener('click', () => completeQuestionnaireResponse())
document.querySelector('form')?.addEventListener('submit', event => {
completeQuestionnaireResponse()
event.preventDefault()
})
}

if (resourceType != null && resourceType[1] === 'Task' && resourceType[2] && (resourceType[3] === undefined || resourceType[4])) {
Expand Down Expand Up @@ -120,7 +123,10 @@ window.addEventListener('DOMContentLoaded', () => {
})

// start process button
document.querySelector('form > fieldset#form-fieldset > div.row-submit > button#start-process')?.addEventListener('click', () => startProcess())
document.querySelector('form')?.addEventListener('submit', event => {
startProcess()
event.preventDefault()
})
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<ul class="error-list" th:for="${i.id}" th:if="${resource.status == 'in-progress'}"></ul>
</div>
<div class="row-submit" th:if="${resource.status == 'in-progress'}">
<button id="complete-questionnaire-response" type="button" name="submit" class="submit">Submit</button>
<button id="complete-questionnaire-response" type="submit" name="submit" class="submit">Submit</button>
</div>
</fieldset>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h3 th:if="${not #lists.isEmpty(task.input)}">Input</h3>
<ul class="error-list" th:for="${i.id}" th:if="${resource.status == 'draft'}"></ul>
</div>
<div class="row-submit" th:if="${resource.status == 'draft'}">
<button id="start-process" type="button" name="submit" class="submit">Start Process</button>
<button id="start-process" type="submit" name="submit" class="submit">Start Process</button>
</div>
</fieldset>
</form>
Expand Down

0 comments on commit 65d52f6

Please sign in to comment.