-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·637 lines (517 loc) · 31.6 KB
/
index.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
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta content="width=device-width,initial-scale=1,maximum-scale=1" name="viewport">
<title>JQuery Populaty</title>
<meta content="Washington Botelho" name="author">
<meta content="jQuery Populaty - A Form Populator" name="description">
<meta content="jquery,plugin,form,formulario,field,fill,filler,populator,popular,populacao,populaty" name="keywords">
<link type="text/css" rel="stylesheet" href="demo/css/application.css">
<script type="text/javascript" src="demo/js/jquery.min.js"></script>
<script type="text/javascript" src="lib/jquery.populaty.min.js"></script>
<link href="/favicon.ico" rel="shortcut icon" type="image/x-icon">
</head>
<body>
<div id="wrapper">
<header role="banner">
<div id="logo">
<h1><a href="http://wbotelhos.com/populaty" title="jQuery Populaty">jQuery Populaty</a></h1>
<p>A Form Populator</p>
</div>
<nav role="navigation">
<ul>
<li><a href="http://github.com/wbotelhos/populaty/archive/0.1.2.zip" title="Download" class="download"><i class="icon-download icon-large"></i>v0.1.2</a></li>
<li><a href="http://github.com/wbotelhos/populaty" title="Github" target="_blank"><i class="icon-github icon-large"></i>Github</a></li>
<li><a href="http://wbotelhos.com/labs" title="yLab" target="_blank"><i class="icon-beaker icon-large"></i>yLab</a></li>
<li><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X8HEP2878NDEG&item_name=jQuery%20Populaty" title="Donate" target="_blank"><i class="icon-heart-empty icon-large"></i>Donate</a></li>
</ul>
</nav>
</header>
<div id="container">
<section role="main">
<article>
<h2 id="default">
<a href="#default">Default:</a>
</h2>
<p>
jQuery Populaty abstract the name annotation used with dot <code>article.title</code> like <a href="http://vraptor.org">VRaptor</a> works or brackets <code>article[title]</code> like <a href="http://rubyonrails.org/">Rails</a> does.<br />
The fields <code>select multiple</code> and <code>checkbox</code> can receive an array with objects <code>[{ 'id': 1 }, { 'id': 2 }]</code> or just the raw values <code>[1, 2]</code>.<br />
If you wonder about arrays without index like <code>article.categories[].id</code> (VRaptor) or <code>article[category_ids][]</code> (Rails), yes, it works too! (:
</p>
<blockquote>The population is based on fields within the form, thus avoiding waste of resource searches across all JSON loaded.</blockquote>
<div class="demo">
<form id="default-demo">
<label for="default-input">Text</label>
<input id="default-input" type="text" name="title" />
<label for="default-select">Select</label>
<select id="default-select" name="article.category.id">
<option></option>
<option value="1">jQuery Capty</option>
<option value="2">jQuery Chrony</option>
</select>
<div class="checkables">
<div class="item">
<input id="default-checkbox-1" type="checkbox" name="article[category_ids][]" value="1" />
<label for="default-checkbox-1">jQuery Modaly</label>
</div>
<div class="item">
<input id="default-checkbox-2" type="checkbox" name="article[category_ids][]" value="2" />
<label for="default-checkbox-2">jQuery Mory</label>
</div>
<div class="item">
<input id="default-checkbox-3" type="checkbox" name="article[category_ids][]" value="3" />
<label for="default-checkbox-3">jQuery Stepy</label>
</div>
</div>
<label for="default-multiple">Select Multiple</label>
<select id="default-multiple" name="article.categories[].id" multiple="true">
<option value="flapy">jQuery Flapy</option>
<option value="flury">jQuery Flury</option>
<option value="gridy">jQuery Gridy</option>
</select>
<div class="checkables">
<div class="item">
<input id="default-radio-1" type="radio" name="article.parent.id" value="1" />
<label for="default-radio-1">jQuery Style</label>
</div>
<div class="item">
<input id="default-radio-2" type="radio" name="article.parent.id" value="2" />
<label for="default-radio-2">jQuery Taby</label>
</div>
<div class="item">
<input id="default-radio-3" type="radio" name="article.parent.id" value="3" />
<label for="default-radio-3">jQuery Treefy</label>
</div>
</div>
<label for="default-textarea">Textarea</label>
<textarea id="default-textarea" name="article[comment]"></textarea>
<input type="button" value="Populate" class="button gray" />
<input type="reset" value="Reset" class="button gray" />
</form>
</div>
<div class="highlight">
<pre>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"text"</span> <span class="na">name=</span><span class="s">"title"</span> <span class="nt">/></span>
<span class="nt"><select</span> <span class="na">name=</span><span class="s">"article.category.id"</span><span class="nt">></span>
<span class="nt"><option></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"1"</span><span class="nt">></span>jQuery Capty<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"2"</span><span class="nt">></span>jQuery Chrony<span class="nt"></option></span>
<span class="nt"></select></span>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"checkbox"</span> <span class="na">name=</span><span class="s">"article[category_ids][]"</span> <span class="na">value=</span><span class="s">"1"</span> <span class="nt">/></span>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"checkbox"</span> <span class="na">name=</span><span class="s">"article[category_ids][]"</span> <span class="na">value=</span><span class="s">"2"</span> <span class="nt">/></span>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"checkbox"</span> <span class="na">name=</span><span class="s">"article[category_ids][]"</span> <span class="na">value=</span><span class="s">"3"</span> <span class="nt">/></span>
<span class="nt"><select</span> <span class="na">name=</span><span class="s">"article.categories[].id"</span> <span class="na">multiple=</span><span class="s">"true"</span><span class="nt">></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"flapy"</span><span class="nt">></span>jQuery Flapy<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"flury"</span><span class="nt">></span>jQuery Flury<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"gridy"</span><span class="nt">></span>jQuery Gridy<span class="nt"></option></span>
<span class="nt"></select></span>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"radio"</span> <span class="na">name=</span><span class="s">"article.parent.id"</span> <span class="na">value=</span><span class="s">"1"</span> <span class="nt">/></span>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"radio"</span> <span class="na">name=</span><span class="s">"article.parent.id"</span> <span class="na">value=</span><span class="s">"2"</span> <span class="nt">/></span>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"radio"</span> <span class="na">name=</span><span class="s">"article.parent.id"</span> <span class="na">value=</span><span class="s">"3"</span> <span class="nt">/></span>
<span class="nt"><textarea</span> <span class="na">name=</span><span class="s">"article[comment]"</span><span class="nt">></textarea></span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="kd">var</span> <span class="nx">json</span> <span class="o">=</span> <span class="p">{</span>
<span class="s1">'title'</span> <span class="o">:</span> <span class="s1">'jQuery Raty'</span><span class="p">,</span>
<span class="s1">'article'</span><span class="o">:</span> <span class="p">{</span>
<span class="s1">'categories'</span> <span class="o">:</span> <span class="p">[{</span> <span class="s1">'id'</span><span class="o">:</span> <span class="s1">'flapy'</span> <span class="p">},</span> <span class="p">{</span> <span class="s1">'id'</span><span class="o">:</span> <span class="s1">'gridy'</span> <span class="p">}],</span>
<span class="s1">'category'</span> <span class="o">:</span> <span class="p">{</span> <span class="s1">'id'</span><span class="o">:</span> <span class="mi">1</span> <span class="p">},</span>
<span class="s1">'category_ids'</span><span class="o">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">],</span>
<span class="s1">'comment'</span> <span class="o">:</span> <span class="s1">'http://wbotelhos.com/labs'</span><span class="p">,</span>
<span class="s1">'parent'</span> <span class="o">:</span> <span class="p">{</span> <span class="s1">'id'</span><span class="o">:</span> <span class="mi">2</span> <span class="p">}</span>
<span class="p">}</span>
<span class="p">};</span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'form'</span><span class="p">).</span><span class="nx">populaty</span><span class="p">({</span> <span class="nx">json</span><span class="o">:</span> <span class="nx">json</span> <span class="p">});</span>
</pre>
</div>
<h2 id="reset">
<a href="#reset">Reset:</a>
</h2>
<p>
<button id="type">Type</button> something on textarea and then trigger the button Populate.<br />
The value will not be removed because the <code>reset</code> options was disabled.<br />
The value will not be replaced too, because nothing came on JSON for this field.
</p>
<div class="demo">
<form id="reset-demo">
<label for="reset-input">Title</label>
<input id="reset-input" type="text" name="title" />
<label for="reset-textarea">Comment</label>
<textarea id="reset-textarea" name="comment"></textarea>
<input type="button" value="Populate" class="button gray" />
<input type="reset" value="Reset" class="button gray" />
</form>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'form'</span><span class="p">).</span><span class="nx">populaty</span><span class="p">({</span>
<span class="nx">json</span> <span class="o">:</span> <span class="p">{</span> <span class="s1">'title'</span><span class="o">:</span> <span class="s1">'jQuery Raty'</span> <span class="p">},</span>
<span class="nx">reset</span><span class="o">:</span> <span class="kc">false</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="json">
<a href="#json">JSON:</a>
</h2>
<p>
The JSON used to populate the fields.<br />
If you set a default JSON for this options, it will be merged with your received JSON.
</p>
<div class="demo">
<form id="json-demo">
<label for="json-input">Title</label>
<input id="json-input" type="text" name="title" />
<label for="json-textarea">Version</label>
<textarea id="json-textarea" name="version"></textarea>
<input type="button" value="Populate" class="button gray" />
<input type="reset" value="Reset" class="button gray" />
</form>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">.</span><span class="nx">fn</span><span class="p">.</span><span class="nx">populaty</span><span class="p">.</span><span class="nx">defaults</span><span class="p">.</span><span class="nx">json</span> <span class="o">=</span> <span class="p">{</span> <span class="nx">version</span><span class="o">:</span> <span class="s1">'0.1.2'</span> <span class="p">};</span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'form'</span><span class="p">).</span><span class="nx">populaty</span><span class="p">({</span> <span class="nx">json</span> <span class="o">:</span> <span class="p">{</span> <span class="s1">'title'</span><span class="o">:</span> <span class="s1">'jQuery Raty'</span> <span class="p">}</span> <span class="p">});</span>
</pre>
</div>
<h2 id="include">
<a href="#include">Include:</a>
</h2>
<p>
Fields that will be handled to be populated.<br />
Check the option <a href="#exclude">exclude</a> to check the fields that will be excluded from this option.<br />
Here we will include just the <code>textarea</code> type, then the <code>text</code> will be ignored.
</p>
<div class="demo">
<form id="include-demo">
<label for="include-input">Text</label>
<input id="include-input" type="text" name="text" />
<label for="include-textarea">Textarea</label>
<textarea id="include-textarea" name="textarea"></textarea>
<input type="button" value="Populate" class="button gray" />
<input type="reset" value="Reset" class="button gray" />
</form>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'form'</span><span class="p">).</span><span class="nx">populaty</span><span class="p">({</span>
<span class="nx">json</span> <span class="o">:</span> <span class="p">{</span> <span class="nx">text</span><span class="o">:</span> <span class="s1">'jQuery Raty'</span><span class="p">,</span> <span class="nx">textarea</span><span class="o">:</span> <span class="s1">'jQuery Gridy'</span> <span class="p">},</span>
<span class="nx">include</span><span class="o">:</span> <span class="s1">'textarea'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="exclude">
<a href="#exclude">Exclude:</a>
</h2>
<p>
This option will exclude elements included on option <a href="#include">include</a>.<br />
He we do the inverse logic used on include options, we exclude the <code>textarea</code> type.
</p>
<div class="demo">
<form id="exclude-demo">
<label for="exclude-input">Text</label>
<input id="exclude-input" type="text" name="text" />
<label for="exclude-textarea">Textarea</label>
<textarea id="exclude-textarea" name="textarea"></textarea>
<input type="button" value="Populate" class="button gray" />
<input type="reset" value="Reset" class="button gray" />
</form>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'form'</span><span class="p">).</span><span class="nx">populaty</span><span class="p">({</span>
<span class="nx">json</span> <span class="o">:</span> <span class="p">{</span> <span class="nx">text</span><span class="o">:</span> <span class="s1">'jQuery Raty'</span><span class="p">,</span> <span class="nx">textarea</span><span class="o">:</span> <span class="s1">'jQuery Gridy'</span> <span class="p">},</span>
<span class="nx">exclude</span><span class="o">:</span> <span class="s1">'textarea'</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="typeful">
<a href="#typeful">Typeful:</a>
</h2>
<p>
Typeful is the fields where we type text inside it, different of a <code>select</code> element.<br />
Here we tell the fields that will use the type strategy to be populated.
</p>
<div class="demo">
<form id="typeful-demo">
<label for="typeful-color">Color</label>
<input id="typeful-color" type="color" name="text_color" />
<label for="typeful-date">Date</label>
<input id="typeful-date" type="date" name="text_date" />
<label for="typeful-datetime">Datetime</label>
<input id="typeful-datetime" type="datetime" name="text_datetime" />
<label for="typeful-datetime-local">Datetime-local</label>
<input id="typeful-datetime-local" type="datetime-local" name="text_datetime-local" />
<label for="typeful-email">E-mail</label>
<input id="typeful-email" type="email" name="text_email" />
<label for="typeful-month">Month</label>
<input id="typeful-month" type="month" name="text_month" />
<label for="typeful-number">Number</label>
<input id="typeful-number" type="number" name="text_number" />
<label for="typeful-range">Range</label>
<input id="typeful-range" type="range" name="text_range" />
<label for="typeful-search">Search</label>
<input id="typeful-search" type="search" name="text_search" />
<label for="typeful-tel">Tel</label>
<input id="typeful-tel" type="tel" name="text_tel" />
<label for="typeful-input">Text</label>
<input id="typeful-input" type="text" name="text_name" />
<label for="exclude-textarea">Textarea</label>
<textarea id="exclude-textarea" name="textareaName"></textarea>
<label for="typeful-time">Time</label>
<input id="typeful-time" type="time" name="text_time" />
<label for="typeful-url">Url</label>
<input id="typeful-url" type="url" name="text_url" />
<label for="typeful-week">Week</label>
<input id="typeful-week" type="week" name="text_week" />
<label for="typeful-hidden">Hidden</label><br />
<input id="typeful-hidden" type="hidden" name="text_hidden" />
<input type="button" value="Populate" class="button gray" />
<input type="reset" value="Reset" class="button gray" />
</form>
</div>
<div class="highlight">
<pre>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"text"</span> <span class="na">name=</span><span class="s">"text_name"</span> <span class="nt">/></span>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"score"</span> <span class="na">name=</span><span class="s">"textareaName"</span> <span class="nt">/></span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'form'</span><span class="p">).</span><span class="nx">populaty</span><span class="p">({</span>
<span class="nx">json</span> <span class="o">:</span> <span class="p">{</span> <span class="nx">text_name</span><span class="o">:</span> <span class="s1">'text type as not applied for'</span><span class="p">,</span> <span class="nx">textareaName</span><span class="o">:</span> <span class="s1">'textarea was applied for and matched'</span> <span class="p">},</span>
<span class="nx">typeful</span><span class="o">:</span> <span class="p">[</span><span class="s1">'textarea'</span><span class="p">]</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="selectable">
<a href="#selectable">Selectable:</a>
</h2>
<p>
Like <a href="#typeful">typeful</a>, here we tell the selectables fields.
</p>
<div class="demo">
<form id="selectable-demo">
<label for="selectable-select">Select</label>
<select id="selectable-select" name="select">
<option></option>
<option value="1">jQuery Capty</option>
<option value="2">jQuery Chrony</option>
</select>
<label for="selectable-multiple">Select Multiple</label>
<select id="selectable-multiple" name="multiple" multiple="true">
<option value="1">jQuery Flapy</option>
<option value="2">jQuery Flury</option>
<option value="3">jQuery Gridy</option>
</select>
<input type="button" value="Populate" class="button gray" />
<input type="reset" value="Reset" class="button gray" />
</form>
</div>
<div class="highlight">
<pre>
<span class="nt"><select</span> <span class="na">name=</span><span class="s">"select"</span><span class="nt">></span>
<span class="nt"><option></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"1"</span><span class="nt">></span>jQuery Capty<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"2"</span><span class="nt">></span>jQuery Chrony<span class="nt"></option></span>
<span class="nt"></select></span>
<span class="nt"><select</span> <span class="na">name=</span><span class="s">"multiple"</span> <span class="na">multiple=</span><span class="s">"true"</span><span class="nt">></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"1"</span><span class="nt">></span>jQuery Flapy<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"2"</span><span class="nt">></span>jQuery Flury<span class="nt"></option></span>
<span class="nt"><option</span> <span class="na">value=</span><span class="s">"3"</span><span class="nt">></span>jQuery Gridy<span class="nt"></option></span>
<span class="nt"></select></span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'form'</span><span class="p">).</span><span class="nx">populaty</span><span class="p">({</span>
<span class="nx">json</span> <span class="o">:</span> <span class="p">{</span> <span class="nx">select</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">multiple</span><span class="o">:</span> <span class="mi">1</span> <span class="p">},</span>
<span class="nx">selectable</span><span class="o">:</span> <span class="p">[</span><span class="s1">'select-one'</span><span class="p">]</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="checkable">
<a href="#checkable">Checkable:</a>
</h2>
<p>
Like <a href="#typeful">typeful</a>, we have the checkable inputs too.
</p>
<div class="demo">
<form id="checkable-demo">
<div class="checkables">
<div class="item">
<input id="checkable-radio-2" type="radio" name="radio" value="1" />
<label for="checkable-radio-2">jQuery Taby</label>
</div>
<div class="item">
<input id="checkable-radio-3" type="radio" name="radio" value="2" />
<label for="checkable-radio-3">jQuery Treefy</label>
</div>
</div>
<div class="checkables">
<div class="item">
<input id="checkable-checkbox-3" type="checkbox" name="checkbox" value="1" />
<label for="checkable-checkbox-3">jQuery Stepy</label>
</div>
</div>
<input type="button" value="Populate" class="button gray" />
<input type="reset" value="Reset" class="button gray" />
</form>
</div>
<div class="highlight">
<pre>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"radio"</span> <span class="na">name=</span><span class="s">"radio"</span> <span class="na">value=</span><span class="s">"1"</span> <span class="nt">/></span>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"radio"</span> <span class="na">name=</span><span class="s">"radio"</span> <span class="na">value=</span><span class="s">"2"</span> <span class="nt">/></span>
<span class="nt"><input</span> <span class="na">type=</span><span class="s">"checkbox"</span> <span class="na">name=</span><span class="s">"checkbox"</span> <span class="na">value=</span><span class="s">"1"</span> <span class="nt">/></span>
</pre>
</div>
<div class="highlight">
<pre>
<span class="nx">$</span><span class="p">(</span><span class="s1">'form'</span><span class="p">).</span><span class="nx">populaty</span><span class="p">({</span>
<span class="nx">json</span> <span class="o">:</span> <span class="p">{</span> <span class="nx">checkbox</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span> <span class="nx">radio</span><span class="o">:</span> <span class="mi">1</span> <span class="p">},</span>
<span class="nx">checkable</span><span class="o">:</span> <span class="p">[</span><span class="s1">'radio'</span><span class="p">]</span>
<span class="p">});</span>
</pre>
</div>
<h2 id="options">
<a href="#options">Options:</a>
</h2>
<div id="checkable" class="option">
<div>checkable <span>['checkbox', 'radio']</span></div>
<p>The checkable fields. This fields will be checked with <code>checked="checked"</code></p>
</div>
<div id="exclude" class="option">
<div>exclude <span>':submit, :reset, :button'</span></div>
<p>Field to be excluded from includeds.</p>
</div>
<div id="include" class="option">
<div>include <span>':input'</span></div>
<p>Fields to be included on population.</p>
</div>
<div id="json" class="option">
<div>json <span>undefined</span></div>
<p>JSON data to populate the fields. You can to use as String or Object.</p>
</div>
<div id="reset" class="option">
<div>reset <span>true</span></div>
<p>Reset or not the form before populate.</p>
</div>
<div id="typeful" class="option">
<div>selectable <span>['select-one', 'select-multiple']</span></div>
<p>The selectable fields. This fields will be selected with <code>selected="selected"</code></p>
</div>
<div id="typeful" class="option">
<div>typeful <span>['color', 'date', 'datetime', 'datetime-local', 'email', 'hidden', 'month', 'number', 'range', 'search', 'tel', 'text', 'textarea', 'time', 'url', 'week']</span></div>
<p>The typeful fields.</p>
</div>
<h2 id="tests">
<a href="#tests">Tests:</a>
</h2>
<p>
This plugin is tested to work better.
<a href="http://wbotelhos.com/populaty/spec/run.html" target="_blank">Check it out!</a>
</p>
</article>
</section>
<div class="author">
<img title="Washington Botelho" src="http://www.gravatar.com/avatar/00c9b483d3c58a12c5f256cf2770d0b8?d=mm" alt="">
<div class="biography">
<p>
Ruby, Java and Python Developer in <a href="http://r7.com" title="R7.com" target="_blank">R7.com</a> Portal.<br />
Bachelor's in Information Systems and certified OCJA 1.0 and OCJP 6.<br />
Helper and learner of the open source community, and designer adventurer.<br />
Also has a passion for dance, skate, jiu-jitsu and Counter Strike Source. (:
</p>
</div>
<div class="social">
<a href="http://github.com/wbotelhos" title="http://github.com/wbotelhos" target="_blank" class="github"></a>
<a href="http://linkedin.com/in/wbotelhos" title="http://linkedin.com/in/wbotelhos" target="_blank" class="linkedin"></a>
<a href="http://twitter.com/wbotelhos" title="http://twitter.com/wbotelhos" target="_blank" class="twitter"></a>
<a href="http://facebook.com/wbotelhos" title="http://facebook.com/wbotelhos" target="_blank" class="facebook"></a>
</div>
</div>
</div>
<footer role="contentinfo">
© 2013 <a href="http://wbotelhos.com" title="wbotelhos.com">wbotelhos.com</a>
</footer>
</div>
<script type="text/javascript">
var json = {
'title' : 'jQuery Raty',
'article': {
'categories' : [{ 'id': 'flapy' }, { 'id': 'gridy' }],
'category' : { 'id': 1 },
'category_ids': [1, 2, 3],
'comment' : 'http://wbotelhos.com/labs',
'parent' : { 'id': 2 }
}
};
$(function() {
$('#default-demo').children(':button').on('click', function() {
$(this).closest('form').populaty({ json: json });
});
$('#type').on('click', function() {
$('#reset-demo').children('textarea').focus();
});
$('#reset-demo').children(':button').on('click', function() {
$(this).closest('form').populaty({
json : { 'title': 'jQuery Raty' },
reset: false
});
});
$('#json-demo').children(':button').on('click', function() {
$.fn.populaty.defaults.json = { version: '0.1.2' };
$(this).closest('form').populaty({ json : { 'title': 'jQuery Raty' } });
$.fn.populaty.defaults.json = undefined;
});
$('#include-demo').children(':button').on('click', function() {
$(this).closest('form').populaty({
json : { text: 'jQuery Raty', textarea: 'jQuery Gridy' },
include: 'textarea'
});
});
$('#exclude-demo').children(':button').on('click', function() {
$(this).closest('form').populaty({
json : { text: 'jQuery Raty', textarea: 'jQuery Gridy' },
exclude: 'textarea'
});
});
$('#typeful-demo').children(':button').on('click', function() {
$(this).closest('form').populaty({
json : { text_name: 'text type as not applied for', textareaName: 'textarea was applied for and matched' },
typeful: ['textarea']
});
});
$('#selectable-demo').children(':button').on('click', function() {
$(this).closest('form').populaty({
json : { select: 1, multiple: 1 },
selectable: ['select-one']
});
});
$('#checkable-demo').children(':button').on('click', function() {
$(this).closest('form').populaty({
json : { checkbox: 1, radio: 1 },
checkable: ['radio']
});
});
});
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-719499234-18', 'wbotelhos.com');
ga('send', 'pageview');
</script>
</body>
</html>