summaryrefslogtreecommitdiff
path: root/public/assets/js/lib/views/details/commentform.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/js/lib/views/details/commentform.js')
-rw-r--r--public/assets/js/lib/views/details/commentform.js22
1 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 6dddd26..708657d 100644
--- a/public/assets/js/lib/views/details/commentform.js
+++ b/public/assets/js/lib/views/details/commentform.js
@@ -13,6 +13,15 @@ var CommentForm = FormView.extend({
this.__super__.initialize.call(this, opt);
this.template = this.$(".template").html();
this.$comment = this.$("[name=comment]");
+ console.log("initialize");
+ },
+
+ show: function () {
+ this.$el.show();
+ },
+
+ hide: function () {
+ this.$el.hide();
},
load: function (thread) {
@@ -40,8 +49,9 @@ var CommentForm = FormView.extend({
validate: function () {
var errors = [];
- var comment = $("[name=comment]").val();
+ var comment = this.$("[name=comment]").val();
var files = this.$("[name=files]").val();
+ console.log(comment, files);
if ((!comment || !comment.length) && !files) {
errors.push("Please enter a comment or add some files.");
}
@@ -52,11 +62,11 @@ var CommentForm = FormView.extend({
$("[name=comment").val("");
$("[name=files").val("");
// window.location.reload()
- console.log(this);
- console.log(this.parent);
+ // console.log(this);
+ // console.log(this.parent);
console.log(data);
- data.comment && this.parent.comments.load([data.comment]);
- data.files && this.parent.files.add(data.files);
- data.files && this.parent.gallery.add(data.files);
+ if (this.opt.onSubmit) {
+ this.opt.onSubmit(data);
+ }
},
});