MVCjQuery数据绑定①列表绑定t.docVIP

  • 2
  • 0
  • 约3.82千字
  • 约 5页
  • 2017-11-20 发布于北京
  • 举报
MVCjQuery数据绑定①列表绑定t

除了绑定Table外,还有其他的循环列表需要绑定。 其实都一样,都是把模版化成数据。 模板的存法用注释的方式只是一种方法。更好的方法自由发挥。目前就是为了取得模板。 比如 用一个Json来存放需要的Template,然后专门放在一个templates.js里或由xml配置的模板然后生成json数据, 需要用的时候直接 templates.tempName 就可以了。 写博文太累了。 特别是自己的思想给别人分享时更累。 我这里也不赘述了。贴下代码吧 代码 ; (function($) { var templateList = []; //存放一般的模板列表 $.fn.bindList = function(args, template, options, async) { var me = this; var url, async, template, dataSource; url = me.attr(datasource); async = me.attr(async) == 0; if (arguments.length 0) { switch (typeof (args)) { case string: url = args; break; case object: dataSource = args; break; } } //args是json switch (arguments.length) { case 1: if (args == null) return me; if (typeof (args) == string) { url = args; } else if (typeof (args) == object) { url = args.url; async = args.async || async; template = args.template || template; options = args.options || options; dataSource = args.data; } break; case 2: // url,async || url,tempalte || data,template if (typeof (arguments[0]) == string) url = arguments[0]; else dataSource = arguments[0]; if (typeof (arguments[1]) == bool) { async = arguments[1]; template = me.getTemplate(); } break; case 3: //url,template,async || url,template,options || data,template,options template = template; options = options; if (typeof (options) == bool) { async = opt

文档评论(0)

1亿VIP精品文档

相关文档