-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdemo4.html
86 lines (80 loc) · 2.73 KB
/
demo4.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
<!doctype html>
<title>Demo 4 - Custom Radio-Checkbox Plugin</title>
<link href="css/demo.css" rel="stylesheet" type="text/css" media="screen" />
<link href="css/custom-radio-checkbox.css" rel="stylesheet" type="text/css" media="screen" />
<h1>Custom Radio-Checkbox Plugin</h1>
<p id="menu">
<a href="demo1.html" title="input inside label">Demo 1</a>
<a href="demo2.html" title="input inside label without 'for' attribute">Demo 2</a>
<a href="demo3.html" title="label next to input">Demo 3</a>
<a class="current-demo" href="demo4.html" title="ajax loaded content">Demo 4</a>
</p>
<h2>Content loaded via AJAX</h2>
<p>*important: Use the <code>"for"</code> attribute in the <code><label></code> to support IE6</p>
<p>Use $('selector').customRadioCheckbox(); to replace radios & checkboxes after the content is loaded</p>
<ul id="tabs" class="clearfix">
<li><a href="#view" class="current">VIEW</a></li>
<li><a href="#html">HTML</a></li>
</ul>
<div id="content">
<div id="view" class="section">
<p><a href="ajax-loaded-content.html" id="load_content">Load content</a></p>
<div id="demo_ajax"></div>
<p><strong>Form result:</strong> <span id="result"></span></p>
</div>
<div id="html" class="section">
<p>The HTML from ajax-loaded-content.html</p>
<pre>
<code id="html_output"></code>
</pre>
<p>And the jQuery to load the content:</p>
<p>After loading the content, form.customRadioCheckbox() is called to replace radios & checkboxes</p>
<pre>
<code>
$(function() {
var link = $('#load_content'),
url = link.attr('href'),
container = $('#demo_ajax');
link.click(function(e) {
e.preventDefault();
container.load(url, function() {
var form = $('#form');
$('#html_output').text(form.parent().html());
// customize radio and checkbox for the loaded content
// and handle the submit function to show the results
form.customRadioCheckbox()
.submit(function(e) {
e.preventDefault();
$('#result').html(form.serialize());
});
});
});
});
</code>
</pre>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="js/jquery.custom-radio-checkbox.js"></script>
<script src="js/demo.js"></script>
<script>
$(function() {
var link = $('#load_content'),
url = link.attr('href'),
container = $('#demo_ajax');
link.click(function(e) {
e.preventDefault();
container.load(url, function() {
var form = $('#form');
$('#html_output').text(form.parent().html());
// customize radio and checkbox for the loaded content
// and handle the submit function to show the results
form.customRadioCheckbox()
.submit(function(e) {
e.preventDefault();
$('#result').html(form.serialize());
});
});
});
});
</script>