diff --git a/source/Ox.UI/js/Form/Form.js b/source/Ox.UI/js/Form/Form.js index db301408..3aeea712 100644 --- a/source/Ox.UI/js/Form/Form.js +++ b/source/Ox.UI/js/Form/Form.js @@ -42,42 +42,42 @@ Ox.Form = function(options, self) { self.itemIds[i] = item.options('id') || item.id; self.$items[i] = Ox.FormItem({element: item}).appendTo(that); item.bindEvent({ - autovalidate: function(data) { - validateForm(i, data.valid); - data.valid && self.$items[i].setMessage(''); - }, - /* - // fixme: should't inputs also trigger a change event? - blur: function(data) { - that.triggerEvent('change', { - id: self.itemIds[i], - data: data - }); - }, - */ - change: function(data) { - // fixme: shouldn't this be key/value instead of id/data? - that.triggerEvent('change', { - id: self.itemIds[i], - data: data - }); - validateItem(i, function(valid) { - validateForm(i, valid); - }); - }, - submit: function(data) { - self.formIsValid && that.submit(); - }, - validate: function(data) { - validateForm(i, data.valid); - // timeout needed for cases where the form is removed - // from the DOM, triggering blur of an empty item - - // in this case, we don't want the message to appear - setTimeout(function() { + autovalidate: function(data) { + validateForm(i, data.valid); + data.valid && self.$items[i].setMessage(''); + }, + /* + // fixme: should't inputs also trigger a change event? + blur: function(data) { + that.triggerEvent('change', { + id: self.itemIds[i], + data: data + }); + }, + */ + change: function(data) { + // fixme: shouldn't this be key/value instead of id/data? + that.triggerEvent('change', { + id: self.itemIds[i], + data: data + }); + validateItem(i, function(valid) { + validateForm(i, valid); + }); + }, + submit: function(data) { + self.formIsValid && that.submit(); + }, + validate: function(data) { + validateForm(i, data.valid); + // timeout needed for cases where the form is removed + // from the DOM, triggering blur of an empty item - + // in this case, we don't want the message to appear + setTimeout(function() { self.$items[i].setMessage(data.valid ? '' : data.message); - }, 0); - } - }); + }, 0); + } + }); }); self.formIsValid = self.options.validate(self.itemIsValid);