Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
让ms-repeat, ms-with在目标都是对象的情况下支持data-with-sorted回调
- Loading branch information
qincheng
committed
Feb 8, 2014
1 parent
50788db
commit bdf363a
Showing
6 changed files
with
127 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title></title> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<script src="avalon.js"></script> | ||
<script> | ||
var model = avalon.define("clear", function(vm) { | ||
vm.array = [1, 2, 3, 4, 5] | ||
}) | ||
setTimeout(function() { | ||
model.array.clear() | ||
setTimeout(function() { | ||
model.array.push("aa", "bb", "cc", "dd") | ||
}, 3000) | ||
}, 3000) | ||
</script> | ||
</head> | ||
<body ms-controller='clear'> | ||
<ol ms-each='array'> | ||
<li>{{el}}</li> | ||
</ol> | ||
<ul> | ||
<li ms-repeat='array'>{{el}}</li> | ||
</ul> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,57 @@ | ||
<!DOCTYPE HTML> | ||
<html id="html"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>测试用例</title> | ||
<script src="avalon.js"></script> | ||
</head> | ||
<body> | ||
<div ms-controller="test"> | ||
<h1>动态更新对象属性</h1> | ||
<p>请耐心等待定时器的变化</p> | ||
<div ms-with="obj"> | ||
<div>{{$val.num}}</div> | ||
</div> | ||
</div> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>测试用例</title> | ||
<script src="avalon.js"></script> | ||
<style> | ||
.with_parent{ | ||
padding:5px; | ||
border:1px solid red; | ||
height:80px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div ms-controller="test"> | ||
<h1>动态更新对象属性</h1> | ||
<p>请耐心等待定时器的变化</p> | ||
<div ms-with="obj" class='with_parent'> | ||
<div class='xxx'>{{$val.num}}</div> | ||
</div> | ||
<div class='repeat_parent' > | ||
<div ms-repeat="obj" title='这是repeat'>{{$val.num}}</div> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
|
||
<script> | ||
window.xxx = false | ||
var model = avalon.define("test", function(vm) { | ||
vm.obj = { | ||
a1: {num: 1111} | ||
} | ||
}); | ||
setTimeout(function() { | ||
|
||
window.xxx = true | ||
model.obj = { | ||
a1: {num: 2222}, a2: {num: 3333} | ||
} | ||
setTimeout(function() { | ||
model.obj.a1.num = 4444 | ||
model.obj.a2.num = 5555 | ||
|
||
var model = avalon.define("test", function (vm) { | ||
vm.obj = { | ||
a1: {num: 1111} | ||
} | ||
}); | ||
setTimeout(function () { | ||
model.obj = { | ||
a1: {num: 2222}, a2: {num: 3333} | ||
} | ||
setTimeout(function () { | ||
model.obj.a1.num = 4444 | ||
model.obj.a2.num = 5555 | ||
setTimeout(function() { | ||
model.obj = { | ||
a1: {num: "MMMMM"}, | ||
a2: {num: "NNNNN"} | ||
} | ||
}, 2000) | ||
|
||
setTimeout(function () { | ||
model.obj.a1.num = 6666 | ||
model.obj.a2.num = 7777 | ||
}, 2000) | ||
|
||
}, 2000) | ||
}, 2000) | ||
|
||
}, 2000) | ||
</script> | ||
</body> | ||
}, 2000) | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>avalon.css</title> | ||
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<script src="avalon.js" type="text/javascript"></script> | ||
<script> | ||
avalon.bindingHandlers.valid = function(data) { | ||
avalon.log("自定义绑定") | ||
avalon.log(data.value) | ||
} | ||
</script> | ||
|
||
<script> | ||
avalon.define("test", function(vm) { | ||
vm.aaa = "xxx" | ||
}) | ||
</script> | ||
</head> | ||
<body> | ||
<div id="aaa" ms-controller="test"> | ||
<div id="bbb" ms-valid="aaa"> | ||
自定义绑定 | ||
</div> | ||
</div> | ||
</body> | ||
</html> |