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

动态添加标签,并绑定数据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张红相应的更新

阅读 1.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题