有没有办法实现类似于我们在 Flex 中的数据绑定?
我注意到在第 9 课 中使用简单的模板引擎支持 dataBinding,但是一旦我更新了我的模型,这些更改就不会传播到我的视图中。
[更新] 这是我的调解员
package mediators
{
import randori.behaviors.AbstractMediator;
import randori.behaviors.SimpleList;
import randori.jquery.Event;
import randori.jquery.JQuery;
/**
* Created by IntelliJ IDEA.
* User: jfernandes
* Date: 23-04-2013
* Time: 14:54
*/
public class IndexMediator extends AbstractMediator
{
[View]
public var names:SimpleList;
[View]
public var change:JQuery;
private var Mike : People = new People("Mike");
private var Roland : People = new People("Roland");
override protected function onRegister():void {
names.data = [Mike,Roland];
change.click(function(event:Event):void
{
this.Mike.name = "Mike Lambriola";
});
}
}
}
人物类
package
{
/**
* Created by IntelliJ IDEA.
* User: jfernandes
* Date: 30-04-2013
* Time: 12:52
*/
public class People
{
public function People(name:String)
{
this.name = name;
}
public var name:String="";
}
}
索引体
<body class="simpleApp">
<ul id="names" class="simpleList">
<li id="template">{name}</li>
</ul>
<input id="change" value="Change values" type="button"/>
</body>
通过单击按钮,我没有看到 Mike 的名字被更新为 Mike Lambriola。