-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi.html
executable file
·736 lines (716 loc) · 38.5 KB
/
api.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>API | surveyJS - JavaScript Survey Creation & Management. Made Easy</title>
<meta name="description" content="JavaScript Survey Creation & Management. Made Easy">
<meta name="keywords" content="survey, question, answer, javascript, plugin, ajax, json">
<meta name="author" content="Valerio Di Punzio">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://fonts.googleapis.com/css?family=Expletus+Sans:500|Raleway:200&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="css/doc.css">
<link rel="stylesheet" href="css/prism.css">
<script defer src="js/prism.js"></script>
<script defer src="js/vendors/jquery-1.12.4.min.js"></script>
<script defer src="js/vendors/bootstrap.bundle.min.js"></script>
<script defer src="js/include.js"></script>
</head>
<body>
<div id="top" class="container-fluid d-flex flex-column">
<div id="menu" class="position-sticky text-right d-flex">
<div class="position-raltive w-100">
<a href="index.html" class="logo">S</a>
<nav class="position-absolute nav-desktop d-none d-md-flex align-items-center">
<a href="index.html" class="p-2 m-2">Home</a>
<a href="get-started.html" class="p-2 m-2">Get Started</a>
<a href="api.html" class="p-2 m-2">API</a>
<a href="demos.html" class="p-2 m-2">Demos</a>
<a href="https://github.com/SimplySayHi/surveyJS" target="_blank" class="github-logo ml-2">
<svg version="1.1" id="Livello_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="28px" height="28px" viewBox="0 0 32 32" enable-background="new 0 0 32 32" xml:space="preserve">
<path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" d="M16,0.112c-8.836,0-16,7.294-16,16.291 C0,23.6,4.584,29.706,10.942,31.86c0.801,0.148 1.093-0.354,1.093-0.785c0-0.387-0.015-1.412-0.021-2.771 c-4.451,0.984-5.39-2.184-5.39-2.184c-0.729-1.881-1.777-2.383-1.777-2.383c-1.452-1.01,0.11-0.99,0.11-0.99 .605,0.115,2.45,1.68,2.45,1.68c1.428,2.488,3.745,1.77,4.657,1.354c0.145-1.053,0.559-1.771,1.016-2.178 c-3.553-0.412-7.288-1.809-7.288-8.051c0-1.778,0.623-3.232,1.646-4.371c-0.164-0.412-0.713-2.068,0.157-4.311 c0,0,1.344-0.438,4.399,1.67c1.276-0.361,2.646-0.543,4.006-0.549c1.359,0.006,2.728,0.188,4.006,0.549 c3.056-2.108,4.396-1.67,4.396-1.67c0.873,2.242,0.323,3.898,0.159,4.311c1.024,1.139,1.644,2.593,1.644,4.371 c0,6.258-3.74,7.635-7.305,8.038c0.574,0.504,1.086,1.498,1.086,3.018c0,2.178-0.02,3.934-0.02,4.469 c0,0.436,0.288,0.941,1.101,0.783C27.421,29.7,32,23.598,32,16.403C32,7.406,24.837,0.112,16,0.112z" />
</svg>
</a>
</nav>
<div class="position-absolute dropdown d-inline-block d-md-none">
<button class="btn dropdown-toggle dropdown-red-outline py-0 px-2" data-toggle="dropdown" type="button">
menu
</button>
<span class="dropdown-menu">
<a class="dropdown-item" href="index.html">Home</a>
<a class="dropdown-item" href="get-started.html">Get Started</a>
<a class="dropdown-item" href="api.html">API</a>
<a class="dropdown-item" href="demos.html">Demos</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="https://github.com/SimplySayHi/surveyJS" target="_blank">View on Github</a>
<a class="dropdown-item" href="https://github.com/SimplySayHi/surveyJS/issues" target="_blank">Report a Bug</a>
</span>
</div>
</div>
</div>
<div class="page-content mt-5 pt-5">
<h4 class="m-0 px-2">surveyJS</h4>
<h1 class="border-0 m-0">API</h1>
<div class="sticky-nav-2 position-sticky d-flex align-items-center overflow-auto">
<a href="#options-list">Options</a> |
<a href="#methods">Methods</a> |
<a href="#prototype-methods">Prototype</a> |
<a href="#builtin-events">Events</a> |
<a href="#templates">Templates</a>
</div>
<div class="mt-5">
<hr>
<p class="m-0">
<b>NOTE</b><br />
surveyJS class extends formJS class ( NOT <span class="badge badge-pill badge-yellow">Lite</span> version ), so it:
</p>
<ul>
<li>
Inherits all formJS features ( properties, options, methods and built-in events ). See <a href="https://www.valeriodipunzio.com/plugins/formJS/api.html" target="_blank">formJS API</a>
</li>
<li>
Has also its own properties, methods, built-in events as listed below
</li>
</ul>
<p>
Keep in mind that <code>options.url</code> is mandatory as shown in page <a href="get-started.html#initialize">Get Started</a>
</p>
<hr>
<p class="m-0">
Features included in Lite version have this badge: <span class="badge badge-pill badge-yellow">Lite</span>
</p>
<div class="toggable-content-outer">
Get a quick peek of features included in Lite version:
<input type="checkbox" class="fake-checkbox btn-toggable-content" id="lite-show-more">
<label class="toggable-label text-red" for="lite-show-more">
<span>show more</span>
<span>close</span>
</label>
<div class="toggable-content">
<div class="d-flex flex-wrap">
<div class="col-sm-6 col-md-3">
<h3 class="small-title mt-3">Options</h3>
<ul>
<li>
cssClasses ( all )
</li>
<li>
initAjaxOptions ( all )
</li>
<li>
messages ( all )
</li>
<li>
showErrorMessage
</li>
<li>
templates ( all )
</li>
</ul>
</div>
<div class="col-sm-6 col-md-3">
<h3 class="small-title mt-3">Methods</h3>
<ul>
<li>
as main version
</li>
</ul>
</div>
<div class="col-sm-6 col-md-3">
<h3 class="small-title mt-3">Prototype</h3>
<ul>
<li>
as main version
</li>
</ul>
</div>
<div class="col-sm-6 col-md-3">
<h3 class="small-title mt-3">Events</h3>
<ul>
<li>
as main version
</li>
</ul>
</div>
<div class="col-sm-6 col-md-3">
<h3 class="small-title mt-3">Templates</h3>
<ul>
<li>
as main version
</li>
</ul>
</div>
</div>
</div>
</div>
<hr>
</div>
<!-- Options -->
<div id="options-list">
<h3 class="sticky-title">Options</h3>
<p>
surveyJS inherits all formJS options and you can initialize the survey with some extra options:
</p>
<div class="panel panel-default panel-transparent no-bg">
<div class="sticky-header card-header bg-white text-dark clearfix d-none d-lg-block">
<div class="d-flex">
<div class="col-xl-4 d-none d-xl-block">
name
</div>
<div class="col-lg-4 col-xl-3">
<span class="d-inline d-xl-none">name, </span>
type
</div>
<div class="col-lg-8 col-xl-5">
description
</div>
</div>
</div>
<div class="card-body">
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-auto col-xl-4">
<pre class="text-green">cssClasses</pre>
<span class="badge badge-pill badge-yellow">Lite</span>
</div>
<div class="w-100 d-xl-none"></div>
<div class="col-lg-4 col-xl-3">
<p><span class="d-inline d-lg-none">Type: </span>object</p>
</div>
<div class="col-lg-8 col-xl-5">
<p>
JS object with keys:
</p>
<ul>
<li>
<span class="text-green">checkbox</span>: ( string ) css class(es) to be applied to checkbox fields
</li>
<li>
<span class="text-green">field</span>: ( string ) css class(es) to be applied to input fields in general ( if the specific one is not found )
</li>
<li>
<span class="text-green">file</span>: ( string ) css class(es) to be applied to field with type="file"
</li>
<li>
<span class="text-green">label</span>: ( string ) css class(es) to be applied to label tags
</li>
<li>
<span class="text-green">radio</span>: ( string ) css class(es) to be applied to radio fields
</li>
<li>
<span class="text-green">wrapper</span>: ( string ) css class(es) to be applied to select fields
<ul>
<li>
<span class="text-green">checkbox</span>: ( string ) css class(es) to be applied to checkbox fields wrapper ( wrapper HTML is defined in <code>options.tempaltes.wrapper.field</code> )
</li>
<li>
<span class="text-green">field</span>: ( string ) css class(es) to be applied to form fields wrapper in general ( if the specific one is not found. Wrapper HTML is defined in <code>options.tempaltes.wrapper.field</code> )
</li>
<li>
<span class="text-green">radio</span>: ( string ) css class(es) to be applied to radio fields wrapper ( wrapper HTML is defined in <code>options.tempaltes.wrapper.field</code> )
</li>
</ul>
</li>
</ul>
<p>
NOTE: specific field types can be added. For example you can add <code>email: 'field-email'</code> and the specified CSS class(es) will be added to all inputs with of type "email".
</p>
</div>
</div>
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-auto col-xl-4">
<pre class="text-green">fieldOptions</pre>
</div>
<div class="w-100 d-xl-none"></div>
<div class="col-lg-4 col-xl-3">
<p><span class="d-inline d-lg-none">Type: </span>object</p>
</div>
<div class="col-lg-8 col-xl-5">
<p>
JS object with field options to run the Form instance for the Survey.<br />
See <a href="https://github.com/SimplySayHi/formJS" target="_blank">formJS</a> plugin for details.
</p>
</div>
</div>
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-auto col-xl-4">
<pre class="text-green">formOptions</pre>
</div>
<div class="w-100 d-xl-none"></div>
<div class="col-lg-4 col-xl-3">
<p><span class="d-inline d-lg-none">Type: </span>object</p>
</div>
<div class="col-lg-8 col-xl-5">
<p>
JS object with field options to run the Form instance for the Survey.<br />
See <a href="https://github.com/SimplySayHi/formJS" target="_blank">formJS</a> plugin for details.
</p>
</div>
</div>
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-auto col-xl-4">
<pre class="text-green">initAjaxOptions</pre>
<span class="badge badge-pill badge-yellow">Lite</span>
</div>
<div class="w-100 d-xl-none"></div>
<div class="col-lg-4 col-xl-3">
<p><span class="d-inline d-lg-none">Type: </span>object</p>
</div>
<div class="col-lg-8 col-xl-5">
<p>
JS object with ajax options passed to the fetch call to retrieve the survey data.
</p>
</div>
</div>
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-auto col-xl-4">
<pre class="text-green">messages</pre>
<span class="badge badge-pill badge-yellow">Lite</span>
</div>
<div class="w-100 d-xl-none"></div>
<div class="col-lg-4 col-xl-3">
<p><span class="d-inline d-lg-none">Type: </span>object</p>
</div>
<div class="col-lg-8 col-xl-5">
<p>
JS object with keys:
</p>
<ul>
<li>
<span class="text-green">error</span>: ( string ) Text to show on generic field error validation. You can also specify a custom error message in JSON file ( see <a href="./get-started.html#json-file">JSON File</a> )
</li>
<li>
<span class="text-green">errorMultiChoice</span>: ( string ) Text to show on error validation of checkboxes with multiple choice.
</li>
<li>
<span class="text-green">maxChoice</span>: ( string ) This text can be used for quesions that let the user choose more than one answer ( checkboxes ).
</li>
</ul>
</div>
</div>
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-auto col-xl-4">
<pre class="text-green">showErrorMessage</pre>
<span class="badge badge-pill badge-yellow">Lite</span>
</div>
<div class="w-100 d-xl-none"></div>
<div class="col-lg-4 col-xl-3">
<p><span class="d-inline d-lg-none">Type: </span>boolean</p>
</div>
<div class="col-lg-8 col-xl-5">
<p>
whether or not to create the field error message inside the HTML ( shown on failed field validation )
</p>
</div>
</div>
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-auto col-xl-4">
<pre class="text-green">templates</pre>
<span class="badge badge-pill badge-yellow">Lite</span>
</div>
<div class="w-100 d-xl-none"></div>
<div class="col-lg-4 col-xl-3">
<p><span class="d-inline d-lg-none">Type: </span>object</p>
</div>
<div class="col-lg-8 col-xl-5">
<p>
Templates used to create the survey.<br />
See <a href="#templates">Templates</a> section for details.
<br /><br />
JS object with keys:
</p>
<ul>
<li>
<span class="text-green">error</span>: ( string ) HTML string to be used as field error message container ( on failed field validation ).
</li>
<li>
<span class="text-green">input</span>: ( string ) HTML string to be used for input fields
</li>
<li>
<span class="text-green">label</span>: ( string ) HTML string to be used for label elements
</li>
<li>
<span class="text-green">loading</span>: ( string ) HTML container and text for the loading box. Used when waiting survey data
</li>
<li>
<span class="text-green">select</span>: ( string ) HTML string to be used for select fields
</li>
<li>
<span class="text-green">textarea</span>: ( string ) HTML string to be used for textarea fields
</li>
<li>
<span class="text-green">wrapper</span>: ( object )
<ul>
<li>
<span class="text-green">field</span>: ( string ) HTML string to be used as wrapper for each field ( input, select, textarea )
</li>
<li>
<span class="text-green">nested</span>: ( string ) HTML string to be used as wrapper for nested fields ( see example in <a href="./demos.html">demos</a> )
</li>
<li>
<span class="text-green">question</span>: ( string ) HTML string to be used as wrapper for each question
</li>
<li>
<span class="text-green">related</span>: ( string ) HTML string to be used as wrapper for related fields ( see example in <a href="./demos.html">demos</a> )
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-auto col-xl-4">
<pre class="text-green">useWebStorage</pre>
</div>
<div class="w-100 d-xl-none"></div>
<div class="col-lg-4 col-xl-3">
<p><span class="d-inline d-lg-none">Type: </span>boolean</p>
</div>
<div class="col-lg-8 col-xl-5">
<p>
Whether or not to use JS session storage to save user answers while compiling the survey.<br />
When reloading the page, JS session storage will be used to polulate the questions with the answers selected/typed by the user.<br />
Note that sessionStorage for the survey will be cleared on submit success.
</p>
</div>
</div>
</div>
<div class="card-footer no-bg">
<p>
Default options:
</p>
<pre>
<code class="language-js">{
cssClasses: {
checkbox: 'form-check-input',
field: 'form-control',
file: 'form-control-file',
label: 'form-check-label',
radio: 'form-check-input',
wrapper: {
checkbox: 'form-check',
field: '',
radio: 'form-check'
}
},
formOptions: {
getFormData: getFormData
},
initAjaxOptions: {
cache: 'no-store',
credentials: 'same-origin',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
method: 'GET',
mode: 'same-origin',
redirect: 'follow',
timeout: 0
},
messages:{
maxChoice: 'answers max',
error: 'Answer is necessary.',
errorMultiChoice: 'You must choose from {{checksMin}} to {{checksMax}} answers.'
},
showErrorMessage: true,
templates: {
error: // SEE TEMPLATES SECTION
input: // SEE TEMPLATES SECTION
label: // SEE TEMPLATES SECTION
loading: // SEE TEMPLATES SECTION
select: // SEE TEMPLATES SECTION
textarea: // SEE TEMPLATES SECTION
wrapper: {
field: // SEE TEMPLATES SECTION
nested: // SEE TEMPLATES SECTION
question: // SEE TEMPLATES SECTION
related: // SEE TEMPLATES SECTION
}
},
useWebStorage: true
}
</code></pre>
</div>
</div>
</div>
<!-- Methods -->
<div id="methods">
<h3 class="sticky-title">Methods</h3>
<p>
surveyJS inherits all formJS methods and has its own:
</p>
<div class="panel panel-default panel-transparent no-bg">
<div class="sticky-header card-header bg-white text-dark clearfix d-none d-lg-block">
<div class="d-flex">
<div class="col-xl-4 d-none d-xl-block">
name
</div>
<div class="col-lg-6 col-xl-5">
<span class="d-inline d-xl-none">name, </span>
description & parameters
</div>
<div class="col-lg-6 col-xl-3">
return value
</div>
</div>
</div>
<div class="card-body">
<div class="">
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-auto col-xl-4">
<pre class="text-green">destroy()</pre>
<span class="badge badge-pill badge-yellow">Lite</span>
</div>
<div class="w-100 d-xl-none"></div>
<div class="col-lg-6 col-xl-5">
<p class="d-lg-none m-0">
Description:
</p>
<p>
This method will:
</p>
<ul>
<li>
Remove all events listeners from the form.
</li>
<li>
Remove the form instance attached to the form element ( by calling method <code>destroy</code> of formJS )
</li>
<li>
<span class="badge badge-pill badge-yellow">Lite</span> Remove the survey instance attached to the form element
</li>
</ul>
</div>
<div class="col-lg-6 col-xl-5">
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Prototype Methods -->
<div id="prototype-methods">
<h3 class="sticky-title">Prototype Methods</h3>
<p>
You can use these methods <b>ONLY</b> from the original Survey object ( not from a new instance ):
</p>
<div class="panel panel-default panel-transparent no-bg">
<div class="sticky-header card-header bg-white text-dark clearfix d-none d-lg-block">
<div class="d-flex">
<div class="col-lg-7 col-xl-4">
name<span class="d-inline d-xl-none">, parameters</span>
</div>
<div class="col-xl-5 d-none d-xl-block">
parameters
</div>
<div class="col-lg-5 col-xl-3">
notes
</div>
</div>
</div>
<div class="card-body">
<div>
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-auto col-xl-4">
<pre class="text-green">setOptions( options )</pre>
<span class="badge badge-pill badge-yellow">Lite</span>
</div>
<div class="w-100 d-xl-none"></div>
<div class="col-lg-6 col-xl-5">
<p class="d-lg-none m-0">
Parameters:
</p>
<ul>
<li>
<span class="text-green">options</span>: JS object with the survey options to override ( see <a href="#options-list">Options section</a> )
</li>
</ul>
</div>
<div class="col-lg-6 col-xl-3">
<p class="d-lg-none m-0">
Description:
</p>
<p>
This will affect <b>ONLY</b> new instances
</p>
</div>
</div>
</div>
</div>
<div class="card-footer no-bg">
<p>
Examples of usage:
</p>
<pre>
<code class="language-js">Survey.setOptions( { showErrorMessage: false } );</code></pre>
</div>
</div>
</div>
<!-- Built-in Events -->
<div id="builtin-events">
<h3 class="sticky-title">Built-in Events</h3>
<p>
surveyJS inherits all formJS built-in events and has its own. By default all built-in events will bubble.
</p>
<div class="panel panel-default panel-transparent no-bg">
<div class="sticky-header card-header bg-white text-dark clearfix d-none d-lg-block">
<div class="d-flex">
<div class="col-lg-6">
name, description
</div>
<div class="col-lg-6">
event detail object
</div>
</div>
</div>
<div class="card-body">
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-6">
<pre class="text-green">sjs:destroy</pre>
<span class="badge badge-pill badge-yellow">Lite</span>
<p class="mt-2">
Emitted after method <code>destroy</code> has been called.
</p>
</div>
<div class="col-lg-6">
</div>
</div>
<div class="clearfix padding-tb-md row-list-separator d-flex flex-wrap">
<div class="col-lg-6">
<pre class="text-green">sjs:init</pre>
<span class="badge badge-pill badge-yellow">Lite</span>
<p class="mt-2">
Emitted when the survey is initialized ( on constructor call ).
</p>
</div>
<div class="col-lg-6">
<p class="d-lg-none">
event detail object
</p>
<p>
In this case, the Promise returned by the AJAX call ( to retrieve JSON data ) will be assigned to <code>event.detail</code>, to which will be passed the ajax response.
</p>
</div>
</div>
</div>
</div>
</div>
<!-- Templates -->
<div id="templates">
<h3 class="sticky-title">Templates</h3>
<p>
You can initialize the survey with your custom HTML templates ( all templates are also included in <span class="badge badge-pill badge-yellow">Lite</span> version ).<br />
NOTE: Use ALL the <code>data-*</code> attributes and placeholders with the curly braces, for example <code>{{answerType}}</code>, in your custom templates.<br />
Below, the default templates:
</p>
<div>
<div class="mt-5">
<p class="m-0">Template <code>error</code></p>
<p class="m-0">For field error message container ( on failed field validation )</p>
<pre>
<code class="language-html"><div class="surveyjs-error-message">{{errorMessage}}</div></code>
</pre>
</div>
<div class="mt-5">
<p class="m-0">Template <code>input</code></p>
<p class="m-0">For input fields</p>
<pre>
<code class="language-html"><input {{fieldAttributes}} name="surveyjs-answer-{{questionNumber}}{{addMoreName}}" class="surveyjs-input surveyjs-{{answerType}} {{fieldClasses}}" /></code>
</pre>
</div>
<div class="mt-5">
<p class="m-0">Template <code>label</code></p>
<p class="m-0">For label elements</p>
<pre>
<code class="language-html"><label for="{{answerCode}}" class="surveyjs-label {{labelClasses}}">{{labelString}}</label></code>
</pre>
</div>
<div class="mt-5">
<p class="m-0">Template <code>loading</code></p>
<p class="m-0">For the loading box. Used when waiting survey data</p>
<pre>
<code class="language-html"><div class="surveyjs-loading" data-surveyjs-loading>Loading...</div></code>
</pre>
</div>
<div class="mt-5">
<p class="m-0">Template <code>select</code></p>
<p class="m-0">For select fields</p>
<pre>
<code class="language-html"><select {{fieldAttributes}} name="surveyjs-answer-{{questionNumber}}{{addMoreName}}" class="surveyjs-select {{fieldClasses}}">
{{optionsHtml}}
</select></code>
</pre>
</div>
<div class="mt-5">
<p class="m-0">Template <code>textarea</code></p>
<p class="m-0">For textarea fields</p>
<pre>
<code class="language-html"><textarea {{fieldAttributes}} name="surveyjs-answer-{{questionNumber}}" class="surveyjs-textarea {{fieldClasses}}"></textarea></code>
</pre>
</div>
<div class="mt-5">
<p class="m-0">Template <code>wrapper.field</code></p>
<p class="m-0">As wrapper for each field ( input, select, textarea )</p>
<pre>
<code class="language-html"><div class="surveyjs-field-wrapper surveyjs-{{answerType}}-wrapper {{wrapperClasses}}">
{{fieldTemplate}}
{{labelTemplate}}
</div></code>
</pre>
</div>
<div class="mt-5">
<p class="m-0">Template <code>wrapper.nested</code></p>
<p class="m-0">As wrapper for nested fields ( see example in <a href="./demos.html">demos</a> )</p>
<pre>
<code class="language-html"><div class="surveyjs-field-wrapper surveyjs-nested-wrapper">
{{labelTemplate}}
<div class="surveyjs-nested-inner">
{{nestedFieldsHTML}}
</div>
</div></code>
</pre>
</div>
<div class="mt-5">
<p class="m-0">Template <code>wrapper.question</code></p>
<p class="m-0">As wrapper for each question.</p>
<p class="m-0"><span class="badge badge-pill badge-yellow">Lite</span> version does NOT include attribute <code>data-formjs-question</code></p>
<pre>
<code class="language-html"><div class="surveyjs-question-wrapper" data-question-id="{{questionId}}" data-formjs-question>
<div class="surveyjs-question-text">{{questionText}}</div>
<div class="surveyjs-answers-wrapper">
{{answersHTML}}
</div>
<div class="surveyjs-errors-wrapper" data-surveyjs-errors>{{errorTemplates}}</div>
</div></code>
</pre>
</div>
<div class="mt-5">
<p class="m-0">Template <code>wrapper.related</code></p>
<p class="m-0">As wrapper for related fields ( see example in <a href="./demos.html">demos</a> and <a href="https://getbootstrap.com/docs/4.3/components/input-group/#checkboxes-and-radios" target="_blank">Bootstrap Input Group</a> )</p>
<pre>
<code class="language-html"><div class="surveyjs-field-wrapper surveyjs-related-wrapper input-group">
<div class="input-group-prepend">
<div class="surveyjs-radio-wrapper input-group-text form-check">
{{fieldTemplate}}
{{labelTemplate}}
</div>
</div>
{{relatedFieldHTML}}
</div></code>
</pre>
</div>
</div>
</div>
</div>
<footer class="text-center mt-5 pt-5 mb-3">
<hr />
<p class="small m-0">
Made with passion by <a href="https://valeriodipunzio.com" target="_blank">Valerio Di Punzio</a>
</p>
</footer>
</div>
</body>
</html>