summaryrefslogtreecommitdiff
path: root/public/assets/js/lib
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-05-14 16:38:21 +0200
committerJules Laplace <julescarbon@gmail.com>2018-05-14 16:38:21 +0200
commit0c8658b2a68a8e12f5e87bc82952e40ae3324a00 (patch)
treea59bf8878f7670ecb8fc89a83ea33b9123c83d0e /public/assets/js/lib
parent5edc86e0f21eeccdaebc4d79964a391936049e86 (diff)
inline comment and delete
Diffstat (limited to 'public/assets/js/lib')
-rw-r--r--public/assets/js/lib/views/details/commentform.js11
-rw-r--r--public/assets/js/lib/views/details/comments.js11
2 files changed, 16 insertions, 6 deletions
diff --git a/public/assets/js/lib/views/details/commentform.js b/public/assets/js/lib/views/details/commentform.js
index 7f04ec3..d4a9149 100644
--- a/public/assets/js/lib/views/details/commentform.js
+++ b/public/assets/js/lib/views/details/commentform.js
@@ -10,8 +10,8 @@ var CommentForm = FormView.extend({
action: "",
- initialize: function(){
- this.__super__.initialize.call(this)
+ initialize: function(opt){
+ this.__super__.initialize.call(this, opt)
this.template = this.$(".template").html()
this.$comment = this.$("[name=comment]")
},
@@ -48,9 +48,12 @@ var CommentForm = FormView.extend({
return errors.length ? errors : null
},
- success: function(){
+ success: function(data){
$("[name=comment").val('')
$("[name=files").val('')
- window.location.reload()
+ // window.location.reload()
+ console.log(this)
+ console.log(this.parent)
+ this.parent.comments.load([data.comment])
}
})
diff --git a/public/assets/js/lib/views/details/comments.js b/public/assets/js/lib/views/details/comments.js
index 688750c..b1c86bb 100644
--- a/public/assets/js/lib/views/details/comments.js
+++ b/public/assets/js/lib/views/details/comments.js
@@ -15,6 +15,8 @@ var CommentsView = FormView.extend({
},
load: function(comments, thread){
+console.log(comments)
+ thread = this.thread = thread || this.thread
if (thread.settings.hootbox) {
comments
.sort((a,b) => cmp(a.date, b.date))
@@ -61,6 +63,10 @@ var CommentsView = FormView.extend({
var $el = this.parse(comment)
$el.insertBefore(this.$formRow)
},
+
+ removeComment: function(id) {
+ this.$("[title='" + id + "']").closest('tr').remove()
+ },
success: function(){
this.prependComment(comment)
@@ -83,8 +89,9 @@ var CommentsView = FormView.extend({
url: "/api/comment/" + id,
headers: { "csrf-token": $("[name=_csrf]").attr("value") },
data: { csrf: csrf() },
- success: function(){
- window.location.reload()
+ success: () => {
+ this.removeComment(id)
+ // window.location.reload()
},
})
}