From a0b5692d077544ea2f44b41ed72f0b3c26b3dcf6 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 24 Jul 2018 15:06:18 +0200 Subject: zipcode check, other error field checkz --- StoneIsland/www/js/lib/view/Serializable.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'StoneIsland/www/js/lib/view') diff --git a/StoneIsland/www/js/lib/view/Serializable.js b/StoneIsland/www/js/lib/view/Serializable.js index f1c61072..4155f102 100755 --- a/StoneIsland/www/js/lib/view/Serializable.js +++ b/StoneIsland/www/js/lib/view/Serializable.js @@ -70,8 +70,9 @@ var SerializableView = View.extend({ update_select: function(e){ var $target = $(e.currentTarget), value = $target.val() var label = $target.find("option").filter(function(){ return this.value === value }).html() - $target.parent().addClass("picked") - $target.parent().find("span").html(label) + var $parent = $target.parent() + $parent.addClass("picked").removeClass("error_hilite") + $parent.find("span").html(label) }, update_date: function(e){ @@ -103,10 +104,17 @@ var SerializableView = View.extend({ console.log("showing errors") console.log(errors) var msgs = [] + this.$('.error_hilite').removeClass('error_hilite') errors.forEach(function(e, i){ - if (i > 0) { return } + // if (i > 0) { return } if (e[0]) { - this.$("[name=" + e[0] + "]").addClass('error_hilite') + var $el = this.$("[name=" + e[0] + "]") + var el = $el[0] + if (el && el.nodeName === 'SELECT') { + $el.parent().addClass('error_hilite') + } else { + $el.addClass('error_hilite') + } } msgs.push(e[1]) }.bind(this)) -- cgit v1.2.3-70-g09d2