Skip to content

Commit bcea0bd

Browse files
authored
Merge pull request #2 from haacked/handle-load-timing
Handle load timing
2 parents a5655ab + 3553d6f commit bcea0bd

File tree

6 files changed

+35
-16
lines changed

6 files changed

+35
-16
lines changed

dist/aspnet-validation.js

Lines changed: 18 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/aspnet-validation.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/aspnet-validation.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aspnet-client-validation",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "Enables ASP.NET MVC client-side validation, without jQuery!",
55
"main": "dist/aspnet-validation.js",
66
"style": "dist/aspnet-validation.css",

src/index.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -863,10 +863,19 @@ export class ValidationService {
863863
*/
864864
bootstrap() {
865865
this.addMvcProviders();
866+
let document = window.document;
867+
if(document.readyState === 'complete') {
868+
this.scan();
869+
}
870+
else {
871+
window.document.addEventListener('DOMContentLoaded', event => {
872+
this.scan();
873+
});
874+
}
875+
}
866876

867-
window.addEventListener('load', event => {
868-
this.scanMessages();
869-
this.scanInputs();
870-
});
877+
private scan() {
878+
this.scanMessages();
879+
this.scanInputs();
871880
}
872881
}

types/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,5 @@ export declare class ValidationService {
200200
* Load default validation providers and scans the entire document when ready.
201201
*/
202202
bootstrap(): void;
203+
private scan;
203204
}

0 commit comments

Comments
 (0)