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

多选框无法执行双向绑定 #1502

Closed
maimaisi opened this issue Jun 21, 2016 · 0 comments
Closed

多选框无法执行双向绑定 #1502

maimaisi opened this issue Jun 21, 2016 · 0 comments

Comments

@maimaisi
Copy link

<!DOCTYPE html>
<html>
<head>
    <title>ms-validate</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <script src="./avalon.js"></script>
    <script>
        var vm = avalon.define({
            $id: "test",
            firstname: '',
            lastname: '',
            username: '',
            password: '',
            list1: ['dog', 'bird', 'cat'],
            list: [{name: 'dog', value: '1'}, {name: 'bird', value: '2'}, {name: 'cat', value: '3'}],
            confirm_password: '',
            email: '',
            agree: false,
            topic: ['1', '2'],
            toggle: false,
            checkDogAndCat: function () {
                vm.topic = ['1', '3']
            }
        })
    </script>
</head>

<body ms-controller="test">
<form class="cmxform" ms-validate="@validate">
    <fieldset>
        <legend>验证完整的表单</legend>
        <p>
            <label for="agree1">请同意我们的声明</label>
            <input type="radio" class="checkbox" id="agree1" value="1" name="agree" ms-duplex-string="@agree">
            <label for="agree2">不同意</label>
            <input type="radio" class="checkbox" id="agree2" value="0" name="agree" ms-duplex-string="@agree">
        </p>

        <legend>主题 (至少选择两个)</legend>


        <label ms-for="el in @list">
            <input ms-duplex="@topic" type="checkbox" ms-attr="{id:el.name,value:el.value}" name="topic">{{el.name}}
        </label>
        <label for="topic" class="error" style="display:none">至少选择两个</label>

        <p>
            <input ms-click="@checkDogAndCat" class="submit" type="button" value="点击勾选dog&cat">
        </p>
    </fieldset>
</form>
</body>

</html>

初始化时topic=['1', '2'] 默认是勾选dog和bird 点击按钮执行方法 topic=['1', '3'] 多选框中cat的选项并未勾选

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