forked from RubyLouvre/avalon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request RubyLouvre#587 from ilife5/master
修复多个视图共存的情况下,向上和向下$fire传播不到的问题
- Loading branch information
Showing
2 changed files
with
56 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>事件在多视图中间的传播</title> | ||
<script src="../avalon.js"></script> | ||
<script type="text/javascript"> | ||
|
||
var ancestorVM = avalon.define({ | ||
$id: "ancestor", | ||
up: function() { | ||
posterity.$fire("up!posterity_up") | ||
} | ||
}); | ||
|
||
ancestorVM.$watch("posterity_up", function() { | ||
alert("up") | ||
}) | ||
|
||
var posterity = avalon.define({ | ||
$id: "posterity" | ||
}); | ||
|
||
</script> | ||
</head> | ||
<body> | ||
|
||
<div> | ||
<div ms-controller="ancestor"></div> | ||
<div ms-controller="ancestor"> | ||
<div ms-controller="posterity"></div> | ||
<button type="button" ms-click="up">up</button> | ||
</div> | ||
</div> | ||
|
||
</body> | ||
</html> |