js 生成的html class屬性失效問題


        var html = '<fieldset class="struct-info" id="SlopeZY"><legend>變坡點(ZY)</legend>';
        html += '<input type="hidden" id="SlopeZYId" name="SlopeZYId"/>';
        if (me.Paras.IsUseCircle != undefined && me.Paras.IsUseCircle == 'True') {
            html += '<div class="row"><label for="SlopeZYStartCircle">開始環號:</label><input id="SlopeZYStartCircle" type="text" class="easyui-numberbox"  precision="0" max="999999999" maxlength="16" min="-999999999" /></div>';
            html += '<div class="row"><label for="SlopeZYEndCircle">結束環號:</label><input id="SlopeZYEndCircle" type="text" class="easyui-numberbox"  precision="0" max="999999999" maxlength="16" min="-999999999"/></div>';
        }
        html += '<div class="row"><label for="SlopeZYStartMileage">開始里程:</label>' + me.Paras.prefix +'<input id="SlopeZYStartMileage1" type="text" class="easyui-validatebox" data-options = "validType:&apos;numberWithZero&apos;"  precision="8" max="999999999" maxlength="16" min="-999999999"  style="width:68px;"/>+<input id="SlopeZYStartMileage2" type="text" class="easyui-validatebox" data-options = "validType:&apos;double&apos;"  precision="8" max="999999999" maxlength="16" min="-999999999"  style="width:68px;"/></div>';
        html += '<div class="row"><label for="SlopeZYEndMileage">結束里程:</label>' + me.Paras.prefix +'<input id="SlopeZYEndMileage1" type="text" class="easyui-validatebox" data-options = "validType:&apos;numberWithZero&apos;" precision="8" max="999999999" maxlength="16" min="-999999999" style="width:68px;"/>+<input id="SlopeZYEndMileage2"  type="text" class="easyui-validatebox" data-options = "validType:&apos;double&apos;"  precision="8" max="999999999" maxlength="16" min="-999999999" style="width:68px;"/></div>';
        html += '</fieldset>';
        html += '<fieldset class="struct-info" id="SlopeYZ"><legend>變坡點(YZ)</legend>';
        html += '<input type="hidden" id="SlopeYZId" name="SlopeYZId"/>';
        if (me.Paras.IsUseCircle != undefined && me.Paras.IsUseCircle == 'True') {
            html += '<div class="row"><label for="SlopeYZStartCircle">開始環號:</label><input id="SlopeYZStartCircle" type="text" class="easyui-numberbox"  precision="0" max="999999999" maxlength="16" min="-999999999"/></div>';
            html += '<div class="row"><label for="SlopeYZEndCircle">結束環號:</label><input id="SlopeYZEndCircle" type="text" class="easyui-numberbox"  precision="0" max="999999999" maxlength="16" min="-999999999"/></div>';
        }
        html += '<div class="row"><label for="SlopeYZStartMileage">開始里程:</label>' + me.Paras.prefix +' <input id="SlopeYZStartMileage1" type="text" class="easyui-validatebox" data-options = "validType:&apos;numberWithZero&apos;" precision="8" max="999999999" maxlength="16" min="-999999999" style="width:68px;"/>+<input id="SlopeYZStartMileage2" type="text" class="easyui-validatebox" data-options = "validType:&apos;double&apos;" precision="8" max="999999999" maxlength="16" min="-999999999"  style="width:68px;"/></div>';
        html += '<div class="row"><label for="SlopeYZEndMileage">結束里程:</label>' + me.Paras.prefix +' <input id="SlopeYZEndMileage1" type="text" class="easyui-validatebox" data-options = "validType:&apos;numberWithZero&apos;" precision="8" max="999999999" maxlength="16" min="-999999999" style="width:68px;"/>+<input id="SlopeYZEndMileage2"  type="text" class="easyui-validatebox" data-options = "validType:&apos;double&apos;" precision="8" max="999999999" maxlength="16" min="-999999999"  style="width:68px;"/></div>';
        html += '</fieldset>';
        $('.content').append(html);

問題描述:通過js添加的輸入框,帶有easyui-validatebox 驗證,但是到前台后,發現驗證失效了。

 

 

解決辦法:在append方法調用后 添加   $.parser.parse($('.content')); 手動激活有效性。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM