You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2. [Issue with sub-requests](Resources/doc/2_2.md)<a name="p_2_2"></a>
64
+
2. [If your forms are placed in sub-requests](Resources/doc/2_2.md)<a name="p_2_2"></a>
65
+
3. If you need to initialize JS validation for your forms separately, or by some event, in this case you need to follow [these steps](Resources/doc/2_3.md) instead of the [chapter 1.3](#p_1_3)
- the second one sends some parameters to this library
24
+
- the third line - this function processes all the forms which have been added to a queue before, and creates for each one its own JS validation model. So that if you have two or more forms on a page - all of them are processed by this function.
25
+
26
+
And if you want customize the initialization, you should leave the first and second lines at the header
-```form``` By default this function processes all the forms which are added to the current queue. But if you want process only one specified form - put here a form name or a FormView instance of the necessary form.
46
+
For example, you have ```comment``` and ```user``` forms on a page:
47
+
```twig
48
+
{{ form(comment) }}
49
+
init_js_validation(comment)
50
+
...
51
+
...
52
+
{{ form(user) }}
53
+
init_js_validation(user)
54
+
```
55
+
56
+
-```onLoad``` By default JS validation models are initialized on DocumentReady event, but if you need to init it later, on some other event, then you have to disable default behavior:
57
+
```twig
58
+
{{ form(form) }}
59
+
init_js_validation(null, false)
60
+
```
61
+
-```wrapper``` this parameter just defines if the result should be wrapped with ```<script type="text/javascript">...</script>``` tag
62
+
63
+
For example, you need to initialize JS validation only after an ajax request:
64
+
```twig
65
+
{{ form(user) }}
66
+
<script type="text/javascript">
67
+
$.ajax({
68
+
...
69
+
...
70
+
complete: function() {
71
+
{{ init_js_validation(null, false, false) }}
72
+
}
73
+
});
74
+
</script>
75
+
```
76
+
-```null``` means that all the available forms will be initialized
77
+
- first ```false``` means that initialization will be performed right at the moment when the 'complete' function is called
78
+
- second ```false``` means that JS code will not be wrapped with the 'script' tag
0 commit comments