forked from jupiterjs/jquerymx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodelBinder.html
More file actions
92 lines (74 loc) · 1.87 KB
/
modelBinder.html
File metadata and controls
92 lines (74 loc) · 1.87 KB
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>slider</title>
<style type='text/css'>
body {font-family: verdana}
.error {border: solid 1px red;}
.error_text { color: red; font-size: 10px;}
td {padding: 3px;}
#sliderWrapper {
border: solid 1px gray;
width: 300px;
height: 30px;
}
#slider {
width: 30px;
height: 30px;
background-color: green;
}
</style>
</head>
<body>
<div id='sliderWrapper'><div id='slider'></div></div>
<input type='text' id='value' />
<textarea id='foo'></textarea>
<select id='bar'>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
<option value='4'>4</option>
<option value='5'>5</option>
<option value='6'>6</option>
<option value='7'>7</option>
<option value='8'>8</option>
<option value='9'>9</option>
<option value='10'>10</option>
</select>
<script type='text/javascript'
src='../../steal/steal.js'>
</script>
<script type='text/javascript'>
steal('jquery/model','mxui/nav/slider').then(function(){
$.fn.hookup = function(inst, attr, type){
inst.bind(attr, {jQ : this},function(ev, val){
if(type){
ev.data.jQ[type]("val", val)
}else{
ev.data.jQ.val(val)
}
})
this.bind("change", function(el, val){
if(type){
inst.attr(attr, val)
}else{
inst.attr(attr, $(this).val())
}
})
var value = inst.attr(attr);
if(type){
this[type]("val",value)
}else{
this.val(value)
}
};
$.Model("Person",{},{});
var person = new Person({age: 1})
$("#slider").mxui_nav_slider({interval: 1, min: 1, max: 10})
.hookup(person,"age","mxui_nav_slider");
$('#value, #foo, #bar').hookup(person,"age");
});
</script>
</body>
</html>