Comment submission now works on main story, need to refresh page after submission to display new comment

This commit is contained in:
Nathan Leniz
2015-03-06 06:08:40 +09:00
parent 8552a06ac6
commit 046a209637
3 changed files with 66 additions and 10 deletions

View File

@@ -183,6 +183,33 @@ $(document).ready(function() {
};
$('#story-submit').on('click', storySubmitButtonHandler);
var commentSubmitButtonHandler = function commentSubmitButtonHandler() {
var data = $('#comment-box').val();
$('#comment-button').unbind('click');
$.post('/stories/comment/submit',
{
data: {
associatedPost: storyId,
body: data,
author: {
picture: user.profile.picture,
userId: user._id,
username: user.profile.username
}
}
})
.fail(function (xhr, textStatus, errorThrown) {
$('#comment-button').bind('click', commentSubmitButtonHandler);
})
.done(function (data, textStatus, xhr) {
//window.location = '/stories/' + JSON.parse(data).storyLink;
});
};
$('#comment-button').on('click', commentSubmitButtonHandler);
});
var profileValidation = angular.module('profileValidation',['ui.bootstrap']);