mvcjquery数据绑定①列表绑定t

mvcjquery数据绑定①列表绑定t

ID:34417795

大小:30.00 KB

页数:5页

时间:2019-03-05

mvcjquery数据绑定①列表绑定t_第1页
mvcjquery数据绑定①列表绑定t_第2页
mvcjquery数据绑定①列表绑定t_第3页
mvcjquery数据绑定①列表绑定t_第4页
mvcjquery数据绑定①列表绑定t_第5页
资源描述:

《mvcjquery数据绑定①列表绑定t》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、除了绑定Table外,还有其他的循环列表需要绑定。其实都一样,都是把模版化成数据。模板的存法用注释的方式只是一种方法。更好的方法自由发挥。目前就是为了取得模板。比如用一个Json来存放需要的Template,然后专门放在一个templates.js里或由xml配置的模板然后生成json数据,需要用的时候直接templates.tempName就可以了。写博文太累了。特别是自己的思想给别人分享时更累。我这里也不赘述了。贴下代码吧代码;(function($){vartemplateList=[];//存放一般的模板列表$.fn.

2、bindList=function(args,template,options,async){varme=this;varurl,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是jsons

3、witch(arguments.length){case1:if(args==null)returnme;if(typeof(args)=="string"){url=args;}elseif(typeof(args)=="object"){url=args.url;async=args.async

4、

5、async;template=args.template

6、

7、template;options=args.options

8、

9、options;dataSource=args.data;}break;case2://url,async

10、

11、

12、url,tempalte

13、

14、data,templateif(typeof(arguments[0])=="string")url=arguments[0];elsedataSource=arguments[0];if(typeof(arguments[1])=="bool"){async=arguments[1];template=me.getTemplate();}break;case3://url,template,async

15、

16、url,template,options

17、

18、data,template,optionste

19、mplate=template;options=options;if(typeof(options)=="bool"){async=options;options=undefined;}break;case4:template=template;options=options;async=async;break;}if((url==undefined

20、

21、url=="")&&dataSource==undefined){returnme;}if(dataSource==undefined){$.ajax({type:"POST"

22、,async:async,url:url,success:function(data){if(data==""

23、

24、data==null)return;data=eval("("+data+")");me.bindListData(data.list

25、

26、data,template,options);}});}else{me.bindListData(dataSource,template,options);}returnme;};$.fn.bindListData=function(data,template,options){

27、varme=this;template=template

28、

29、me.getTemplate();this.empty();varresultTemplate=replaceTemplate(template,data);varprepend,append,dvalue;if(options!=undefined){prepend=options.prepend;append=options.append;dvalue=options.dvalue;}if(prepend!=undefined){resultTemplate=pr

30、epend+resultTemplate;}if(append!=undefined){resultTemplate+=append;}this.html(resultTemplate);//绑定控件的默认值if(this.attr("type")=="select-one"

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。