Skip to content
Snippets Groups Projects
Commit 43d77dbb authored by Demian Katz's avatar Demian Katz
Browse files

Improved function order.

parent 23184cfc
No related merge requests found
......@@ -45,6 +45,38 @@ function setUpCheckRequest() {
});
}
function deleteRecordComment(element, recordId, recordSource, commentId) {
var url = path + '/AJAX/JSON?' + $.param({method:'deleteRecordComment',id:commentId});
$.ajax({
dataType: 'json',
url: url,
success: function(response) {
if (response.status == 'OK') {
$($(element).parents('li')[0]).remove();
}
}
});
}
function refreshCommentList(recordId, recordSource) {
var url = path + '/AJAX/JSON?' + $.param({method:'getRecordCommentsAsHTML',id:recordId,'source':recordSource});
$.ajax({
dataType: 'json',
url: url,
success: function(response) {
if (response.status == 'OK') {
$('#commentList').empty();
$('#commentList').append(response.data);
$('#commentList a.deleteRecordComment').unbind('click').click(function() {
var commentId = $(this).attr('id').substr('recordComment'.length);
deleteRecordComment(this, recordId, recordSource, commentId);
return false;
});
}
}
});
}
function registerAjaxCommentRecord() {
$('form[name="commentRecord"]').unbind('submit').submit(function(){
if (!$(this).valid()) { return false; }
......@@ -79,38 +111,6 @@ function registerAjaxCommentRecord() {
});
}
function deleteRecordComment(element, recordId, recordSource, commentId) {
var url = path + '/AJAX/JSON?' + $.param({method:'deleteRecordComment',id:commentId});
$.ajax({
dataType: 'json',
url: url,
success: function(response) {
if (response.status == 'OK') {
$($(element).parents('li')[0]).remove();
}
}
});
}
function refreshCommentList(recordId, recordSource) {
var url = path + '/AJAX/JSON?' + $.param({method:'getRecordCommentsAsHTML',id:recordId,'source':recordSource});
$.ajax({
dataType: 'json',
url: url,
success: function(response) {
if (response.status == 'OK') {
$('#commentList').empty();
$('#commentList').append(response.data);
$('#commentList a.deleteRecordComment').unbind('click').click(function() {
var commentId = $(this).attr('id').substr('recordComment'.length);
deleteRecordComment(this, recordId, recordSource, commentId);
return false;
});
}
}
});
}
$(document).ready(function(){
// register the record comment form to be submitted via AJAX
registerAjaxCommentRecord();
......
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