diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2017-12-22 07:46:52 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2017-12-22 07:47:41 +0100 |
| commit | fe7ee50baa8f96836ecefa2088d129b90705125c (patch) | |
| tree | d148e031ac882a1af0ea35629d6cd27c560d50fb /public/assets/js/lib/views/index/threadform.js | |
| parent | fa4ed0f3b1ce5decfc6ee59d38e63e78a7793de4 (diff) | |
new mail alert
Diffstat (limited to 'public/assets/js/lib/views/index/threadform.js')
| -rw-r--r-- | public/assets/js/lib/views/index/threadform.js | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/public/assets/js/lib/views/index/threadform.js b/public/assets/js/lib/views/index/threadform.js index 7a8e8ed..b2e1963 100644 --- a/public/assets/js/lib/views/index/threadform.js +++ b/public/assets/js/lib/views/index/threadform.js @@ -1,18 +1,18 @@ var ThreadForm = FormView.extend({ - + el: "#thread_form", - + events: { }, - + action: "/api/thread", method: "POST", - + initialize: function(){ this.__super__.initialize.call(this) this.template = this.$(".template").html() }, - + load: function(selected_keyword){ $.get("/api/keywords", function(data){ var tags = {} @@ -21,17 +21,19 @@ var ThreadForm = FormView.extend({ var opt = document.createElement('option') opt.value = kw opt.innerHTML = kw - if (selected_keyword === kw) { - opt.setAttribute("selected", "selected") - } tags[kw] = opt }) var sorted = Object.keys(tags).sort().map(kw => tags[kw]) this.$('[name=keyword]').append(sorted) + if (selected_keyword) { + this.$('[name=keyword]').val(selected_keyword) + } else { + this.$('[name=keyword]').val('unsorted') + } $("body").removeClass('loading') }.bind(this)) }, - + validate: function(){ var errors = [] var title = this.$("[name=title]").val() @@ -52,4 +54,4 @@ var ThreadForm = FormView.extend({ } window.location.href = "/details/" + data.id } -})
\ No newline at end of file +}) |
