zoukankan      html  css  js  c++  java
  • Handler实现数据模板

    <ul id="ulList">
    <li onclick="show('{ID}‘,'{Title}')"><a href="somepage.html?id={ID}" >{Title}</a><br />
    {Content}</li>
    </ul>

    $.get("Handler.ashx?n=" + Math.random(), { action: "getNews" }, function(data) {
    var list = $.parseJSON(data);
    var ul = $("#ulList");
    var html = "";
    for (var i = 0; i < list.length; i++) {
    html += ul.data("tpl").format(list[i]);
    }
    ul.html(html);
    })

    $(function() {
        var ulList = $("#ulList");
        ulList.data("tpl",ulList.html()).empty();
      }

    public class News
    {
    public int ID { get; set; }
    public string Title { get; set; }
    public string Content { get; set; }
    }
    //handler里用了上面第一个问题的解决方法
      hs.Add("getNews", delegate()
      {
        List<News> list = new List<News>()
        {
          new News(){ ID=1,Title="title1",Content="Content1"},
          new News(){ ID=2,Title="title2",Content="Content2"},
          new News(){ ID=3,Title="title3",Content="Content3"},
        };
        return jss(list);
      });
    

      

  • 相关阅读:
    layoutSubviews, setNeedsLayout, layoutIfNeeded
    UIViewController 专题
    UIBarButtonItem
    ios method swizzling
    Method Swizzling
    ios逆向工程
    IOS中通知中心NSNotificationCenter应用总结
    Swift 进阶
    swift 2.0 语法 字符串
    C++Builder中MessageBox的基本用法
  • 原文地址:https://www.cnblogs.com/zhubenxi/p/5160517.html
Copyright © 2011-2022 走看看