MCPcopy Create free account
hub / github.com/dresende/node-orm2 / enhanceMessage

Function enhanceMessage

examples/anontxt/public/app.js:84–112  ·  view source on GitHub ↗
($msg)

Source from the content-addressed store, hash-verified

82 }
83
84 function enhanceMessage($msg) {
85 $msg.find('.comments .new-comment form').submit(function (e) {
86 var $form = $(e.target);
87 var $msg = $form.parents('.message:first');
88 var msgId = $msg.data('id')
89
90 e.preventDefault();
91
92 $.ajax({
93 url : '/message/' + msgId + '/comments',
94 method : 'post',
95 data : $form.serialize()
96 }).done(function (data) {
97 if ('errors' in data) {
98 showAlert(
99 "error",
100 "Errors occurred whilst adding comment" +
101 renderErrors(data.errors)
102 );
103 } else {
104 $(renderComment(data)).insertBefore($msg.find('.new-comment'));
105 showAlert("info", "Comment saved!");
106 }
107 $form[0].reset();
108 }).fail(function (xhr, err, status) {
109 showAlert('error', xhr.status + ', ' + xhr.responseText);
110 });
111 });
112 }
113
114 function loadMessages() {
115 $.ajax({

Callers 2

loadMessagesFunction · 0.85
app.jsFile · 0.85

Calls 4

showAlertFunction · 0.85
renderErrorsFunction · 0.85
renderCommentFunction · 0.85
findMethod · 0.65

Tested by

no test coverage detected