diff options
Diffstat (limited to 'public/assets/js/vendor/view/formview.js')
| -rw-r--r-- | public/assets/js/vendor/view/formview.js | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/public/assets/js/vendor/view/formview.js b/public/assets/js/vendor/view/formview.js index d77ff51..613738e 100644 --- a/public/assets/js/vendor/view/formview.js +++ b/public/assets/js/vendor/view/formview.js @@ -35,7 +35,7 @@ var FormView = View.extend({ serialize: function(){ var fd = new FormData(), hasCSRF = false - + this.$("input[name], select[name], textarea[name]").each( function(){ if (this.type == "file") { if (this.files.length > 0) { @@ -44,7 +44,7 @@ var FormView = View.extend({ } else if (this.type == "password") { if (this.value.length > 0) { - fd.append(this.name, SHA1.hex('lol$' + this.value + '$vvalls')) + fd.append(this.name, SHA1.hex('bucky$' + this.value + '$bucky')) } } else { @@ -53,10 +53,10 @@ var FormView = View.extend({ } }); - if (! hasCSRF) { - fd.append("_csrf", $("[name=_csrf]").val()) - } - +// if (! hasCSRF) { +// fd.append("_csrf", $("[name=_csrf]").attr("value")) +// } +// return fd }, @@ -85,42 +85,51 @@ var FormView = View.extend({ url: action, type: this.method, data: this.serialize(), + headers: { "csrf-token": $("[name=_csrf]").attr("value") }, dataType: "json", processData: false, contentType: false, + success: function(response){ + +console.log(response) + if (response.error) { + var errors = [] + for (var key in response.error.errors) { + errors.push(response.error.errors[key].message); + } + if (errorCallback) { + errorCallback(errors) + } + else { + this.showErrors(errors) + } + return + } + else { + if (successCallback) { + successCallback(response) + } + if (this.success) { + this.success(response) + } + } + + + }.bind(this), + error: function(response){ + }.bind(this), + complete: function(response){ + if (this.useMinotaur) { + Minotaur.hide() + } + }.bind(this), }) if (this.useMinotaur) { Minotaur.show() } - - request.done($.proxy(function (response) { - if (this.useMinotaur) { - Minotaur.hide() - } - if (response.error) { - var errors = [] - for (var key in response.error.errors) { - errors.push(response.error.errors[key].message); - } - if (errorCallback) { - errorCallback(errors) - } - else { - this.showErrors(errors) - } - return - } - else { - if (successCallback) { - successCallback(response) - } - if (this.success) { - this.success(response) - } - } - }, this)); - } + + }, }) |
