Skip to content

Instantly share code, notes, and snippets.

@nickstamas
Forked from anonymous/gist:5043319
Last active December 14, 2015 06:29
Show Gist options
  • Select an option

  • Save nickstamas/5043459 to your computer and use it in GitHub Desktop.

Select an option

Save nickstamas/5043459 to your computer and use it in GitHub Desktop.
$(function(){
$('#response_note').enableSubmitOnType();
});
jQuery.fn.enableSubmitOnType = function() {
$("input[type=submit]").attr("disabled", "disabled");
this.keyup(function(e){
var textInput = $(e.target);
var formEl = $(textInput).closest('form');
var submitButton = $(formEl).find('input[type=submit]');
$(submitButton).removeAttr("disabled", "disabled");
});
return this;
}
# Forms
<form accept-charset="UTF-8" action="/responses/177" class="simple_form edit_response form-inline" data-remote="true" id="edit_response_177" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /><input name="authenticity_token" type="hidden" value="I/YJZ0s7Ua1ugbJDvRX1M5CvzrjhuAuZqFAi/zOQFsM=" /></div>
<input id="response_job_id" name="response[job_id]" type="hidden" value="77" />
<input id="response_checklist_id" name="response[checklist_id]" type="hidden" value="50" />
<input id="response_workday_id" name="response[workday_id]" type="hidden" value="1" />
<input id="response_submission_id" name="response[submission_id]" type="hidden" value="36" />
<input name="response[completed]" type="hidden" value="0" /><input checked="checked" id="response_completed" name="response[completed]" type="checkbox" value="1" /> <strong>Clean sink</strong><span class="pull-right stamp"><strong>
[Tom, 11:15 pm!]
</strong></span></br>
<a href="#workday_1_checklist_50_job_77" data-toggle="collapse">note...</a>
<div id="workday_1_checklist_50_job_77" class="collapse">
<textarea class="autoresizer" cols="40" id="response_note" name="response[note]" placeholder="Optional details..." rows="1">
fdsafdasdsfdf</textarea>
<div class="form-actions">
<input class="btn btn-primary" name="commit" type="submit" value="Update note" />
<a href="#workday_1_checklist_50_job_77" data-toggle="collapse" class="btn">Cancel</a>
</div>
</div>
</form>
<form accept-charset="UTF-8" action="/responses/179" class="simple_form edit_response form-inline" data-remote="true" id="edit_response_179" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /><input name="_method" type="hidden" value="put" /><input name="authenticity_token" type="hidden" value="I/YJZ0s7Ua1ugbJDvRX1M5CvzrjhuAuZqFAi/zOQFsM=" /></div>
<input id="response_job_id" name="response[job_id]" type="hidden" value="78" />
<input id="response_checklist_id" name="response[checklist_id]" type="hidden" value="50" />
<input id="response_workday_id" name="response[workday_id]" type="hidden" value="1" />
<input id="response_submission_id" name="response[submission_id]" type="hidden" value="36" />
<input name="response[completed]" type="hidden" value="0" /><input id="response_completed" name="response[completed]" type="checkbox" value="1" /> <strong>Restock toilet paper</strong> - Let manager know if fewer than two rolls remain in the cupboard.<span class="pull-right stamp"><strong>
[Tom, 10:35 pm!]
</strong></span></br>
<a href="#workday_1_checklist_50_job_78" data-toggle="collapse">note...</a>
<div id="workday_1_checklist_50_job_78" class="collapse">
<textarea class="autoresizer" cols="40" id="response_note" name="response[note]" placeholder="Optional details..." rows="1">
blah blah</textarea>
<div class="form-actions">
<input class="btn btn-primary" name="commit" type="submit" value="Update note" />
<a href="#workday_1_checklist_50_job_78" data-toggle="collapse" class="btn">Cancel</a>
</div>
</div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment