Commit 44d414e8 by Will Daly

Enable/disable save and submit buttons based on input text

parent 18b14421
......@@ -44,7 +44,7 @@
<ul class="list list--actions response__submission__actions">
<li class="list--actions__item">
<button type="submit" id="submission__save" class="action action--save submission__save">Save Your Progress</button>
<button type="submit" id="submission__save" class="action action--save submission__save is--disabled">Save Your Progress</button>
<span class="tip">You may continue to work on your response until you submit it.</span>
</li>
</ul>
......@@ -54,7 +54,7 @@
<div class="step__actions">
<ul class="list list--actions">
<li class="list--actions__item">
<a aria-role="button" href="#" id="step--response__submit" class="action action--submit step--response__submit">
<a aria-role="button" href="#" id="step--response__submit" class="action action--submit step--response__submit is--disabled">
<span class="copy">Submit your response and move to the next step</span>
<i class="ico icon-caret-right"></i>
</a>
......
......@@ -68,6 +68,15 @@ OpenAssessment.BaseUI.prototype = {
var sel = $('#openassessment__response', ui.element);
sel.replaceWith(html);
// Install change handler for textarea (to enable submission button)
$('#submission__answer__value', ui.element).keyup(
function(eventData) {
var blankSubmission = ($(this).val() === '');
$('#step--response__submit', ui.element).toggleClass('is--disabled', blankSubmission);
$('#submission__save', ui.element).toggleClass('is--disabled', blankSubmission);
}
);
// Install a click handler for submission
$('#step--response__submit', ui.element).click(
function(eventObject) { ui.submit(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment