diff options
author | tof <> | 2008-03-14 14:42:39 +0000 |
---|---|---|
committer | tof <> | 2008-03-14 14:42:39 +0000 |
commit | 3d8d3f7169814c33c1dc829ef61cb3281d8c146c (patch) | |
tree | 3a85b3eb1b327d79ce549808ffb95f7c86f2239a /framework/Web/Javascripts/source | |
parent | ef2989e39255dba36cbbf20a1c5400fe7667ed26 (diff) |
Fixed #671, #721
Diffstat (limited to 'framework/Web/Javascripts/source')
-rw-r--r-- | framework/Web/Javascripts/source/prado/validator/validation3.js | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/framework/Web/Javascripts/source/prado/validator/validation3.js b/framework/Web/Javascripts/source/prado/validator/validation3.js index 45e9aa43..47c031c4 100644 --- a/framework/Web/Javascripts/source/prado/validator/validation3.js +++ b/framework/Web/Javascripts/source/prado/validator/validation3.js @@ -410,8 +410,11 @@ Prado.WebUI.TValidationSummary.prototype = return;
}
- var refresh = update || this.visible == false || this.options.Refresh != false;
-
+ var refresh = update || this.visible == false || this.options.Refresh != false;
+ // Also, do not refresh summary if at least 1 validator is waiting for callback response.
+ // This will avoid the flickering of summary if the validator passes its test
+ refresh = refresh && validators.any(function(v) { return !v.requestDispatched; });
+
if(this.options.ShowSummary != false && refresh)
{
this.updateHTMLMessages(this.getMessages(validators));
@@ -1150,15 +1153,57 @@ Prado.WebUI.TCustomValidator = Class.extend(Prado.WebUI.TBaseValidator, Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator,
{
validatingValue : null,
+ invoker : null,
/**
+ * Override the parent implementation to store the invoker, in order to
+ * re-validate after the callback has returned
+ * Calls evaluateIsValid() function to set the value of isValid property.
+ * Triggers onValidate event and onSuccess or onError event.
+ * @param HTMLElement element that calls for validation
+ * @return boolean true if valid.
+ */
+ validate : function(invoker)
+ {
+ this.invoker = invoker;
+
+ //try to find the control.
+ if(!this.control)
+ this.control = $(this.options.ControlToValidate);
+
+ if(!this.control || this.control.disabled)
+ {
+ this.isValid = true;
+ return this.isValid;
+ }
+
+ if(typeof(this.options.OnValidate) == "function")
+ {
+ if(this.requestDispatched == false)
+ this.options.OnValidate(this, invoker);
+ }
+
+ if(this.enabled && !this.control.getAttribute('disabled'))
+ this.isValid = this.evaluateIsValid();
+ else
+ this.isValid = true;
+
+ // Only update the message if the callback has already return !
+ if (!this.requestDispatched)
+ this.updateValidationDisplay(invoker);
+
+ this.observeChanges(this.control);
+
+ return this.isValid;
+ },
+
+ /**
* Calls custom validation function.
*/
evaluateIsValid : function()
{
value = this.getValidationValue();
if(!this.requestDispatched && (""+value) != (""+this.validatingValue))
- //if((""+value) != (""+this.validatingValue))
{
this.validatingValue = value;
request = new Prado.CallbackRequest(this.options.EventTarget, this.options);
@@ -1182,6 +1227,13 @@ Prado.WebUI.TActiveCustomValidator = Class.extend(Prado.WebUI.TBaseValidator, if(typeof(this.options.onSuccess) == "function")
this.options.onSuccess(request,data);
this.updateValidationDisplay();
+ this.manager.updateSummary(this.group);
+ // Redispatch initial request if any
+ if (this.invoker instanceof Prado.CallbackRequest)
+ {
+ this.invoker.dispatch();
+ }
+
},
callbackOnFailure : function(request, data)
|