summaryrefslogtreecommitdiff
path: root/StoneIsland/www/js/vendor/view/serializable.js
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/www/js/vendor/view/serializable.js')
-rw-r--r--StoneIsland/www/js/vendor/view/serializable.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/StoneIsland/www/js/vendor/view/serializable.js b/StoneIsland/www/js/vendor/view/serializable.js
index db996f23..3c069880 100644
--- a/StoneIsland/www/js/vendor/view/serializable.js
+++ b/StoneIsland/www/js/vendor/view/serializable.js
@@ -22,15 +22,16 @@ var SerializableView = View.extend({
Object.keys(presence_msgs).forEach(function(k){
if (! data[k]) errors.push( [ k, presence_msgs[k] ] )
})
- this.validate_fields && this.validate_fields(errors)
+ this.validate_fields && this.validate_fields(data, errors)
this.cc && this.cc.validate(errors)
this.address && this.address.validate(errors)
- return errors.length ? errors : null
+ return { errors: errors, data: data }
},
show_errors: function(errors){
var msgs = []
- errors.forEach(function(e){
+ errors.forEach(function(e, i){
+ if (i > 0) { return }
this.$("[name=" + e[0] + "]").addClass('error_hilite')
msgs.push(e[1])
}.bind(this))
@@ -46,9 +47,9 @@ var SerializableView = View.extend({
save: function(e){
e && e.preventDefault()
- var errors = this.validate()
- if (errors) {
- this.show_errors(errors)
+ var valid = this.validate()
+ if (valid.errors.length) {
+ this.show_errors(valid.errors)
return
}
else {
@@ -57,7 +58,7 @@ var SerializableView = View.extend({
app.curtain.show("loading")
this.action({
- data: data,
+ data: valid.data,
success: function(data){
app.curtain.hide("loading")
this.success(data)