Skip to content

Commit 0f8b23f

Browse files
Merge pull request #10 from global-source/dev
Dynamic DOM handling [ES6 and Native]
2 parents 41bcd31 + 796d27c commit 0f8b23f

File tree

3 files changed

+41
-9
lines changed

3 files changed

+41
-9
lines changed

src/demo/index2.html

+9-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</div>
1414
<div>
1515
<label></label>
16-
<input type="text" data-allow="onlyAlpha" name="name2">
16+
<input type="text" data-allow="onlyAlpha" name="name2" required>
1717
</div>
1818
<div>
1919
<label></label>
@@ -25,20 +25,20 @@
2525
</div>
2626
</form>
2727

28-
<script src="./../js/validatorNew.js"></script>
29-
<!--<script src="./../js/validatorNew.es6.js"></script>-->
28+
<!--<script src="./../js/validatorNew.js"></script>-->
29+
<script src="./../js/validatorNew.es6.js"></script>
3030
<script>
3131

32-
// var form = new jsValidator().init({
33-
// form: 'form2submit',
34-
// forceFilter: true
35-
// });
36-
37-
var form = jsValidator.init({
32+
var form = new jsValidator().init({
3833
form: 'form2submit',
3934
forceFilter: true
4035
});
4136

37+
// var form = jsValidator.init({
38+
// form: 'form2submit',
39+
// forceFilter: true
40+
// });
41+
4242
</script>
4343
</body>
4444
</html>

src/js/validatorNew.es6.js

+16
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class jsValidator {
4545
this.forceFilter = false;
4646
// To Filter the First load.
4747
this.initialLoad = true;
48+
// Global options.
49+
this.option = false;
4850
}
4951

5052
// Initiating the Validator.
@@ -53,6 +55,8 @@ class jsValidator {
5355

5456
jsLogger.table(option);
5557

58+
// To Update global options.
59+
this.option = option;
5660
// Update "jsSettings" to global object.
5761
this.jsSettings = new jsSettings().init(option);
5862
// Update "jsForm" to global object.
@@ -85,6 +89,18 @@ class jsValidator {
8589
}
8690
}
8791

92+
// To update the DOM to make action listener.
93+
update() {
94+
// To Update global options.
95+
let option = this.option;
96+
// Update "jsSettings" to global object.
97+
this.jsSettings = new jsSettings().init(option);
98+
// Update "jsForm" to global object.
99+
this.jsForm = new jsForm().init(option);
100+
// Initiate form error setup.
101+
this.jsFormError = new jsFormError().init();
102+
}
103+
88104
// To checking all elements from registered form.
89105
check() {
90106
// Loading JS Form.

src/js/validatorNew.js

+16
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,14 @@ var jsValidator = {
4141
forceFilter: false,
4242
// To Filter the First load.
4343
initialLoad: true,
44+
// Global options.
45+
option: false,
4446
// Initiating the Validator.
4547
init: function (option) {
4648
jsLogger.table(option);
4749

50+
// To Update global options.
51+
this.option = option;
4852
// Updating the filter flag to global.
4953
this.onlyFilter = option.onlyFilter;
5054
// Update "jsSettings" to global object.
@@ -78,6 +82,18 @@ var jsValidator = {
7882
});
7983
}
8084
},
85+
// To Refresh the DOM and enable Dynamic-Elements to Access.
86+
update: function () {
87+
var option = this.option;
88+
// Updating the filter flag to global.
89+
this.onlyFilter = option.onlyFilter;
90+
// Update "jsSettings" to global object.
91+
this.jsSettings = jsSettings.init(option);
92+
// Update "jsForm" to global object.
93+
this.jsForm = jsForm.init(option);
94+
// Initiate form error setup.
95+
this.jsFormError = jsFormError.init();
96+
},
8197
// To checking all elements from registered form.
8298
check: function () {
8399
var status = false;

0 commit comments

Comments
 (0)