diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-08-25 18:15:40 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-08-25 18:15:40 -0400 |
| commit | 9257818363269a2893c1a7ee61adb497f749e38f (patch) | |
| tree | 4c387fd37bbe93d2bdd529757a055101c4ab6884 /public/assets/javascripts/ui/lib/FormView.js | |
| parent | 124a698130f39992a1b47dcc8f32ef30c61a00eb (diff) | |
collab stuff 90% there
Diffstat (limited to 'public/assets/javascripts/ui/lib/FormView.js')
| -rw-r--r-- | public/assets/javascripts/ui/lib/FormView.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/public/assets/javascripts/ui/lib/FormView.js b/public/assets/javascripts/ui/lib/FormView.js index ab33bc0..17b748a 100644 --- a/public/assets/javascripts/ui/lib/FormView.js +++ b/public/assets/javascripts/ui/lib/FormView.js @@ -33,7 +33,7 @@ var FormView = View.extend({ }, serialize: function(){ - var fd = new FormData() + var fd = new FormData(), hasCSRF = false this.$("input[name], select[name], textarea[name]").each( function(){ if (this.type == "file") { @@ -48,9 +48,14 @@ var FormView = View.extend({ } else { fd.append(this.name, this.value); + hasCSRF = hasCSRF || this.name == "_csrf" } }); + if (! hasCSRF) { + fd.append("_csrf", $("[name=_csrf]").val()) + } + return fd }, @@ -71,9 +76,12 @@ var FormView = View.extend({ return } } + + var action = typeof this.action == "function" ? this.action() : this.action + if (! action) return var request = $.ajax({ - url: this.action, + url: action, type: this.method, data: this.serialize(), dataType: "json", |
