Changeset 15416
- Timestamp:
- 10/07/08 06:35:00 (3 months ago)
- Location:
- dijit/trunk
- Files:
-
- 1 added
- 1 modified
-
form/Form.js (modified) (5 diffs)
-
tests/form/test_validStatePerformance.html (added)
Legend:
- Unmodified
- Added
- Removed
-
dijit/trunk/form/Form.js
r15254 r15416 301 301 isValid: function(){ 302 302 // summary: make sure that every widget that has a validator function returns true 303 this._invalidWidgets = []; 303 304 return dojo.every(this.getDescendants(), function(widget){ 304 return widget.disabled || !widget.isValid || widget.isValid(); 305 }); 305 var isValid = widget.disabled || !widget.isValid || widget.isValid(); 306 if(!isValid){ 307 this._invalidWidgets.push(widget); 308 } 309 return isValid; 310 }, this); 306 311 }, 307 312 … … 313 318 }, 314 319 315 _widgetChange: function( ){320 _widgetChange: function(widget){ 316 321 // summary: connected to a widgets onChange function - update our 317 322 // valid state, if needed. 318 var isValid = this.isValid(); 323 var isValid = this._lastValidState; 324 if(widget && !widget.disabled && widget.isValid){ 325 this._invalidWidgets = dojo.filter(this._invalidWidgets||[], function(w){ 326 return (w != widget); 327 }, this); 328 if(!widget.isValid()){ 329 this._invalidWidgets.push(widget); 330 } 331 isValid = (this._invalidWidgets.length === 0); 332 } 319 333 if (isValid !== this._lastValidState){ 320 334 this._lastValidState = isValid; … … 340 354 ), 341 355 function(widget){ 342 return _this.connect(widget, "validate", "_widgetChange");356 return _this.connect(widget, "validate", dojo.hitch(_this, "_widgetChange", widget)); 343 357 } 344 358 ); … … 346 360 // Call the widget change function to update the valid state, in 347 361 // case something is different now. 348 this._widgetChange( );362 this._widgetChange(null); 349 363 }, 350 364 … … 355 369 // yet. 356 370 this._changeConnections = []; 371 this._lastValidState = this.isValid(); 357 372 this.connectChildren(); 358 this._lastValidState = this.isValid();359 373 } 360 374 });