Disable submit buttons while performing validation

This commit is contained in:
Naoki Takezoe
2014-07-13 03:48:44 +09:00
parent 2e11d6dd78
commit 258d53b7a6
2 changed files with 8 additions and 0 deletions

View File

@@ -11,11 +11,13 @@
<script>
$(function(){
var callback = function(data){
$('#update-comment-@commentId, #cancel-comment-@commentId').removeAttr('disabled');
$('#commentContent-@commentId').empty().html(data.content);
prettyPrint();
};
$('#update-comment-@commentId').click(function(){
$('#update-comment-@commentId, #cancel-comment-@commentId').attr('disabled', 'disabled');
$.ajax({
url: '@path/@owner/@repository/issue_comments/edit/@commentId',
type: 'POST',
@@ -26,11 +28,13 @@ $(function(){
}).done(
callback
).fail(function(req) {
$('#update-comment-@commentId, #cancel-comment-@commentId').removeAttr('disabled');
$('#error-edit-content-@commentId').text($.parseJSON(req.responseText).content);
});
});
$('#cancel-comment-@commentId').click(function(){
$('#update-comment-@commentId, #cancel-comment-@commentId').attr('disabled', 'disabled');
$.get('@path/@owner/@repository/issue_comments/_data/@commentId', callback);
return false;
});

View File

@@ -14,11 +14,13 @@ $(function(){
$('#edit-content').elastic();
var callback = function(data){
$('#update, #cancel').removeAttr('disabled');
$('#issueTitle').empty().text(data.title);
$('#issueContent').empty().html(data.content);
};
$('#update').click(function(){
$('#update, #cancel').attr('disabled', 'disabled');
$.ajax({
url: '@path/@owner/@repository/issues/edit/@issueId',
type: 'POST',
@@ -29,11 +31,13 @@ $(function(){
}).done(
callback
).fail(function(req) {
$('#update, #cancel').removeAttr('disabled');
$('#error-edit-title').text($.parseJSON(req.responseText).title);
});
});
$('#cancel').click(function(){
$('#update, #cancel').attr('disabled', 'disabled');
$.get('@path/@owner/@repository/issues/_data/@issueId', callback);
return false;
});