summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/vendor/ModalFormView.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/vendor/ModalFormView.js')
-rw-r--r--public/assets/javascripts/vendor/ModalFormView.js31
1 files changed, 16 insertions, 15 deletions
diff --git a/public/assets/javascripts/vendor/ModalFormView.js b/public/assets/javascripts/vendor/ModalFormView.js
index 3cc2691..f99317b 100644
--- a/public/assets/javascripts/vendor/ModalFormView.js
+++ b/public/assets/javascripts/vendor/ModalFormView.js
@@ -35,26 +35,13 @@ var ModalFormView = ModalView.extend({
}
},
- submit: function(e){
- e.preventDefault()
-
- this.$errors.hide().css("opacity", 0.0);
-
- if (this.validate) {
- var errors = this.validate()
- if (errors && errors.length) {
- this.showErrors(errors)
- return
- }
- }
-
+ serialize: function(){
var fd = new FormData()
this.$("input[name], select[name], textarea[name]").each( function(){
if (this.type == "file") {
if (this.files.length > 0) {
fd.append(this.name, this.files[0]);
- console.log(this.name)
}
}
else if (this.type == "password") {
@@ -66,11 +53,25 @@ var ModalFormView = ModalView.extend({
fd.append(this.name, $(this).val());
}
});
+ },
+
+ submit: function(e){
+ e.preventDefault()
+
+ this.$errors.hide().css("opacity", 0.0);
+
+ if (this.validate) {
+ var errors = this.validate()
+ if (errors && errors.length) {
+ this.showErrors(errors)
+ return
+ }
+ }
var request = $.ajax({
url: this.action,
type: this.method,
- data: fd,
+ data: this.serialize(),
dataType: "json",
processData: false,
contentType: false,