Skip to content

Commit

Permalink
update example
Browse files Browse the repository at this point in the history
  • Loading branch information
qincheng committed Sep 8, 2014
1 parent da95420 commit 0f7784d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 28 deletions.
44 changes: 44 additions & 0 deletions examples/$watch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<script src="../avalon.js" ></script>
<script>
var model = avalon.define({
$id: "test",
aaa: "2",
bbb: "2",
$ccc: "1",
ddd: "1",
$skipArray: ["ddd"],
click: function(a) {
model[a] = new Date - 0
}
})
model.$watch("aaa", function(a, b) {
console.log("aaa", a, b)
})
model.$watch("bbb", function(a, b) {
console.log("bbb", a, b)
})
model.$watch("$ccc", function(a, b) {
console.log("$ccc", a, b)
})
model.$watch("ddd", function(a, b) {
console.log("ddd", a, b)
})
</script>
<style>
.ms-hover div:hover{
background:yellowgreen;
}
</style>
</head>
<body ms-controller="test" class='ms-hover'>
<div ms-click="click('aaa')">{{aaa}}</div>
<div ms-click="click('bbb')">{{bbb}}</div>
<div ms-click="click('$ccc')">{{$ccc}}</div>
<div ms-click="click('ddd')">{{ddd}}</div>
</body>
</html>
52 changes: 24 additions & 28 deletions test1.html
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<title>avalon入门</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="avalon.js" ></script>
<title>ms-attr-*</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<script src="avalon.js"></script>

<script>
var model = avalon.define({
$id: "test",
array: [{a: 222}, {a: 333}],
"aaa-eee": "ddd",
aaa: "bbb ddd"
avalon.define("aaa", function(vm) {
vm.e = "true"

})
model.$watch("aaa-eee", function(e){
alert(e)
avalon.define("bbb", function(vm) {
vm.e = "false"

})
setTimeout(function() {
model.array.set(1, {a: 444})
// model.$fire("aaa-eee", "oooo")
}, 2000)

</script>
<style>

.bbb{
background:pink;
.active {
background: goldenrod;
}
.ddd{
border: 1px solid green;
.readonly{
border:1px solid blueviolet;
}

</style>

</head>
<body ms-controller="test" ms-class="{{aaa}}">
<div >
<ul>
<li ms-repeat="array">{{el.a}}</li>
</ul>
</div>
<body>
<form method="get" action="aaa.html" ms-controller="bbb">
<div ms-controller="aaa">
<div ms-class="{{e}}111">11111
</div>
</div>
</form>
</body>
</html>
</html>

0 comments on commit 0f7784d

Please sign in to comment.