I am using this jquery-comments plugin for a small conversation functionality. and this works good.
Only issue is it does not refresh comments after we post a comment and just adds new comment row, so if another person make a comment from his side, it will not show until we refresh full page.
So i am able to fetch the new comments from database by ajax, which works good.
getLastestComments: function(){
var new_comments_array = null;
$.ajax({
url: 'index.php?route=extension/module/getLastestComment&user_token='+ this.options.primaryId,
async: false,
success: function(json) {
new_comments_array = json['data'];
},
});
return new_comments_array ;
}
Only thing i am not able to configure is how can i refresh this Comments(Render Again); I have tried, couple of things but no luck. Like inside the postComment : function
I adds : this.render() [this function loads on pageload and render comments], this.createComments(), etc.
postComment: function(ev) {
var self = this;
var sendButton = $(ev.currentTarget);
var commentingField = sendButton.parents('.commenting-field').first();
// Set button state to loading
this.setButtonState(sendButton, false, true);
// alert(this.options.primaryId);
// Create comment JSON
var commentJSON = this.createCommentJSON(commentingField);
// Reverse mapping
commentJSON = this.applyExternalMappings(commentJSON);
var success = function(commentJSON) {
self.createComment(commentJSON);
commentingField.find('.close').trigger('click');
// Reset button state
self.setButtonState(sendButton, false, false);
};
// this.getComments();
// self.getComments();
var error = function() {
// Reset button state
self.setButtonState(sendButton, true, false);
};
this.options.postComment(commentJSON, success, error);
this.options.refresh();
console.log(this.createComments());
this.render();
this.createComments();
// if(this.options.enableAttachments && this.options.enableNavigation) this.createAttachments();
},
Quite a simple thing, but Anyone have any guess about this? Thanks for your time