template render in javascript
art-template for github
html中添加js:
<script type="text/javascript" src="~/Scripts/template-web.js" asp-append-version="true"></script>
html中添加template-ui:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <script id= "logs_Template" type= "text/html" > <table style= "padding:0;text-align:center" > {{each ChangeLogs}} <tr> <td><div class = "input-control text size3" >修改人:{{$value.OperateUserName}}</div></td> <td><div class = "input-control text size3" >修改时间:{{$value.OperateShowTime}}</div></td> <td><div class = "input-control text size3" >查看详情 <span class = 'content-show-control' onclick= "walletChangeRecordCreator.detailClickEvent(this)" ><i class = 'fa fa-angle-down' ></i></span></div></td> </tr> <!--分割线--> <tr> <td colspan= "4" style= "padding-right:0;" > <div style= "border-top: 1px dashed #ccc" ></div> </td> </tr> <tr class = "change-detail-properties-tr" style= "display:none" > <td colspan= "4" style= "padding:0;" > <table> <tr> <td><div class = "input-control text size3" ><b>字段名</b></div></td> <td><div class = "input-control text size3" ><b>修改前</b></div></td> <td><div class = "input-control text size3" ><b>修改后</b></div></td> </tr> {{each $value.ChangedProperties}} <tr> <td><div class = "input-control text size3" >{{$value.PropertyShowName}}</div></td> <td><div class = "input-control text size3" >{{$value.OldValue}}</div></td> <td><div class = "input-control text size3" >{{$value.NewValue}}</div></td> </tr> {{/each}} </table> </td> </tr> {{/each}} </table> </script> |
js中post调用获取数据之后重新渲染template-ui
post调用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | getLogsPost: function () { walletChangeRecordCreator.getEle$( ".wallet_change_record_part" ).hide(); $.ajax({ data: { WalletId: "@Model.WalletId" }, url: "@Url.Content(" ~/ChargesCenter/WalletChangeLogsDetail ")" , type: 'POST' , dataType: 'json' , cache: false , success: function (data) { if (data.Success && data.Content) { walletChangeRecordCreator.fileLogsContent(data.Content); //$("#PostSucess").val(true); } else if (!data.Success) { showAlert(data.Message); }; }, error: function (jqXHR, error, errorThrown) { if (jqXHR.status == 0 || jqXHR.status == 401) { window.top.location = logoutUrl; } else { showAlert(error); }; } }); }, |
template-ui重新渲染
1 2 3 4 5 6 7 | fileLogsContent: function (jsonData) { if (!jsonData) return ; //console.log(jsonData); var fdHtml = template( "logs_Template" , jsonData); walletChangeRecordCreator.getEle$( ".wallet_change_record_part " ).html(fdHtml); walletChangeRecordCreator.getEle$( ".wallet_change_record_part" ).show(); }, |
分类:
javascript
, UI
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· 没有源码,如何修改代码逻辑?
· NetPad:一个.NET开源、跨平台的C#编辑器
· 面试官:你是如何进行SQL调优的?
2017-11-07 Machine.config与web.config