标签:ntb sel span tag ctc selectall 常用方法 mon ble
格式化时间:
1 <script type="text/html" id="timeTpl"> 2 {{# var fn = function(){ 3 var date=new Date(d.createtime); 4 var d1=date.getDate(); 5 var y=date.getFullYear(); 6 var m=date.getMonth() + 1; 7 return y+‘/‘+m+‘/‘+d1; 8 }; if(true){ }} 9 {{ fn() }} 10 {{# } }} 11 </script>
密码显示 ***** :
1 <script type="text/html" id="pwd"> 2 {{# var fn = function(){ 3 return ‘***‘; 4 }; if(true){ }} 5 {{ fn() }} 6 {{# } }} 7 </script>
状态栏:
1 <script type="text/html" id="barDemo1"> 2 <a class="layui-btn layui-btn-mini" id="edit" lay-event="edit">保存</a> 3 <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">冻结</a> 4 </script>
1 <script type="text/html" id="usernameTpl"> 2 <a href="/?table-demo-id={{d.id}}" class="layui-table-link" target="_blank">{{ d.username }}</a> 3 </script>
远程获取数据:
1 <script type="text/javascript"> 2 3 layui.use(‘form‘, function() { 4 var form = layui.form; 5 $("#tname").children().remove(); 6 $.ajax({ 7 type : "post", 8 url : "../user/selectallusersrole.do?role=3", 9 dataType : "json", 10 sync : "false", 11 success : function(data) { 12 for (var a = 0; a < data.data.length; a++) { 13 $("#tname").append( 14 "<option class=‘tname‘ value="+data.data[a].id+" >"+ data.data[a].urealname + "</option>") 15 } 16 form.render(‘select‘); //用ajax追加的需要这样渲染一下 17 18 }, 19 error : function() { 20 } 21 }) 22 23 $("#urealname").children().remove(); 24 $.ajax({ 25 type : "post", 26 url : "../user/selectallusersrole.do?role=4", 27 dataType : "json", 28 sync : "false", 29 success : function(data) { 30 for (var a = 0; a < data.data.length; a++) { 31 $("#urealname").append( 32 "<option class=‘name‘ value="+data.data[a].id+" >"+ data.data[a].urealname + "</option>") 33 } 34 form.render(‘select‘); //用ajax追加的需要这样渲染一下 35 36 }, 37 error : function() { 38 } 39 }) 40 $("#cname").children().remove(); 41 $.ajax({ 42 type : "post", 43 url : "../class/selectclass.do", 44 dataType : "json", 45 sync : "false", 46 success : function(data) { 47 for (var a = 0; a < data.data.length; a++) { 48 $("#cname").append( 49 "<option class=‘tname‘ value="+data.data[a].cid+" >"+ data.data[a].cname + "</option>") 50 } 51 form.render(‘select‘); //用ajax追加的需要这样渲染一下 52 53 }, 54 error : function() { 55 } 56 }) 57 58 //form.on(‘select(username)‘, function(data) {//给隐藏的input赋值(机构id) 59 //$("#yincang").val(data.value); 60 //}); 61 62 }); 63 </script>
表单获取Value数据:
1 function formLoad(element,data){ 2 var input = document.getElementById(element).getElementsByTagName(‘input‘); 3 for(var i =0;i < input.length;i++){ 4 var inputname = input[i].name; 5 for(var j in data){ 6 if(inputname == j){ 7 input[i].value = data[j]; 8 } 9 } 10 } 11 }
标签:ntb sel span tag ctc selectall 常用方法 mon ble
原文地址:http://www.cnblogs.com/jiangwz/p/7899424.html