首页 > 代码库 > juicer模板引擎使用
juicer模板引擎使用
http://www.juicer.name/<script src=http://www.mamicode.com/"~/Scripts/jquery-1.8.2.min.js"></script><script src=http://www.mamicode.com/"~/Scripts/juicer.js"></script>页面模板 <div class="refund-bottom" id="divRefundRecord"> </div><script id="tpl" type="text/template"> {&each ObjectData as it,index} <div class="lectuer-info"> <span class="photos"><img alt="" src=http://www.mamicode.com/"~/Content/images/pics/50x50.jpg"></span> <div class="cont"> <span class="clearfix"><em class="fl-l">${it.UserId}</em><em class="fl-r">${it.CreateTime}</em></span> <span>${it.Explain}</span> <span class="leave-img"> </span> </div> </div> {&/each}</script>// 调用JS $(function () { GetList();}); function GetList() { var refundId = 100006; $.ajax({ url: ‘/Refund/GetRefundRecordList‘, type: ‘POST‘, dataType: "json", data: { refundId: refundId }, async: true, success: function (result) { $("#divRefundRecord").html(juicer($("#tpl").html(), result)); //result是一个JSON对象, result.ObjectData 是一个数据集合属性,提供遍历模板使用 } });}//后台代码public ActionResult GetRefundRecordList(int refundId) { ResponseModel responseModel = new ResponseModel(); using (var db = new BusinessEntities()) { var RefundList = db.RefundRecord.Where(e => e.RefundId == refundId).Select(e => new { e.UserId, e.Explain, e.CreateTime }).ToList(); responseModel.ObjectData = RefundList; responseModel.IsSuccess = true; return Content(JsonConvert.SerializeObject(responseModel)); } }
juicer模板引擎使用
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。