Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ms-include 如何实现重新加载当前子模板 #1996

Open
Horjer opened this issue May 17, 2017 · 0 comments
Open

ms-include 如何实现重新加载当前子模板 #1996

Horjer opened this issue May 17, 2017 · 0 comments

Comments

@Horjer
Copy link

Horjer commented May 17, 2017

ms-include和ms-include-src 指令如何实现重新加载当前子模板呢?
我尝试了重新赋值原有值,却得不到刷新,还有什么其他途径可以解决这个问题的没有?

测试代码如下:

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="http://cdn.bootcss.com/avalon.js/1.5.8/avalon.js"></script>
    <script>
        var model = avalon.define({
            $id: "test",
            page: "form",
			rows:[{"name":1},{"name":2}],
            change: function() {
                model.page = model.page === "form" ? "list" : "form";
            },
            reload:function(){
                model.page = model.page === "form" ? "form" : "list";
                console.log("尝试重新赋值来刷新,但是失败了!")
            }
        })
    </script>
</head>
<body ms-controller="test">
    <script type="avalon" id="form">
        测试:<input type="text">
    </script>
    <script type="avalon" id="list">
        搜索:<input type="text">
        <div ms-repeat="rows">{{el.name}}</div>
    </script>
    <p>
        <button ms-click="change" type="button">切换子模板</button>
        <button ms-click="reload" type="button">重新加载当前子模板</button>
    </p>
    <div ms-include="page"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant