动态添加标签 并增加ms-duplex属性

发布于 2022-09-07 23:08:19 字数 5322 浏览 22 评论 0

动态添加标签,并绑定数据ms-duplex,发现没有绑定成功

修改过添加的代码改成modelData['+dataCount+'].PreTime也不行。如果刚开始就已经写上去的就能实现绑定。

相关代码

var tempmodel = avalon.define({
    $id: "GZBG",
    modelData: [{ "RBDate": ComFunJS.getnowdate("yyyy-mm-dd"), "LeiBie": "", "Files": "", "ChaoSongUser": "" }, { "RBContent": "", "RBWCQK": "", "Describe": "", "PreTime": "", "StartDate": "", "EndDate": "", "ActTime": "","BranchName": "" }],
    addLogD: function() {
        var count = $(this).parent().parent().parent().children("tr");
        var trcont = count.length - 1;
        var dataCount = count.length;
          var m={ "RBContent": "", "RBWCQK": "", "Describe": "", "PreTime": "", "StartDate": "", "EndDate": "", "ActTime": "","BranchName": "" };
        tempmodel.modelData.push(m);
        var htmlStr1 = ' <tr class="tr' + trcont + '">';
        htmlStr1 += '<th>' + count.length + '</th>';
        htmlStr1 += ' <th calss="form-group text-center">';
        htmlStr1 += '    <input type="text" name="" class="form-control" ms-duplex=" tempmodel.modelData['+dataCount+'] .RBContent" />';
        htmlStr1 += ' </th>';
        htmlStr1 += ' <th calss="form-group text-center">';
        htmlStr1 += '    <input type="text" name="" class="form-control" ms-duplex=" tempmodel.modelData['+dataCount+'] .Describe" />';
        htmlStr1 += ' </th>';
        htmlStr1 += ' <th calss="form-group text-center">';
        htmlStr1 += '     <span class="bn" onclick="dellogd(this)">删除</span>';
        htmlStr1 += '  </th>';
        htmlStr1 += '</tr>';
        $(this).parent().parent().before(htmlStr1);
        var htmlStr2 = '';
        htmlStr2 += '<tr class="tr' + trcont + '">';
        htmlStr2 += '    <th calss="form-group">';
        htmlStr2 += '        <input type="text" name="" class="form-control szhl_require" ms-duplex=" tempmodel.modelData['+dataCount+'].PreTime">';
        htmlStr2 += '    </th>';
        htmlStr2 += '    <th calss="form-group">';
        htmlStr2 += '        <input type="text" name="" class="form-control szhl_form_date_time" ms-duplex=" tempmodel.modelData['+dataCount+'].StartDate" />';
        htmlStr2 += '    </th>';
        htmlStr2 += '    <th calss="form-group">';
        htmlStr2 += '        <input type="text" name="" class="form-control szhl_form_date_time" ms-duplex="tempmodel.modelData['+ dataCount+'].EndDate" />';
        htmlStr2 += '    </th>';
        htmlStr2 += '    <th calss="form-group">';
        htmlStr2 += '        <input type="text" name="" class="form-control" ms-duplex="tempmodel.modelData['+ dataCount+'].ActTime" />';
        htmlStr2 += '    </th>';
        htmlStr2 += '    <th calss="form-group">';
        htmlStr2 += '        <select class="form-control" ms-duplex="tempmodel.[modelData'+dataCount+'].RBWCQK" style="width:100px">';
        htmlStr2 += '            <option></option>';
        htmlStr2 += '            <option>已完成</option>';
        htmlStr2 += '            <option  selected = "selected" >进行中</option>';
        htmlStr2 += '        </select>';
        htmlStr2 += '    </th>';
        htmlStr2 += '    <th calss="form-group">';
        htmlStr2 += '        <input type="text" name="" class="form-control" ms-duplex="tempmodel.[modelData'+dataCount+'].BranchName" />';
        htmlStr2 += '    </th>';
        htmlStr2 += '</tr>';
        $("#content").append(htmlStr2);
     
    });

页面原有的元素是这样的

<tr>
                        <th calss="form-group">
                            <input type="text" name="" class="form-control szhl_require" ms-duplex="modelData[1].PreTime">
                        </th>
                        <th calss="form-group">
                            <input type="text" name="" class="form-control szhl_form_date_time" ms-duplex="modelData[1].StartDate" />
                        </th>
                        <th calss="form-group">
                            <input type="text" name="" class="form-control szhl_form_date_time" ms-duplex="modelData[1].EndDate" />
                        </th>
                        <th calss="form-group">
                            <input type="text" name="" class="form-control" ms-duplex="modelData[1].ActTime" />
                        </th>
                        <th calss="form-group">
                            <select class="form-control" ms-duplex="modelData[1].RBWCQK" style="width:100px">
                                <option>已完成</option>
                                <option selected="selected">进行中</option>
                            </select>
                        </th>
                        <th calss="form-group">
                            <input type="text" name="" class="form-control" ms-duplex="modelData[1].BranchName" />
                        </th>
                    </tr>

你期待的结果是什么?实际看到的错误信息又是什么?

通过调用addLogD还能实现双向绑定修改了页面的内容,还能在数据 tempmodel.modelData张红相应的更新

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文