一些总结

1,  事件代理导致多次提交

a)         delegate绑定代理函数,使用undelegate解除绑定

b)         使用if(!isDelegate){},判断是否绑定过事件,如果里面有用到调用此函数的json时,会使json不能及时更新,将json保存在me.CacheJson = json中,可以修复此缺陷

2,  一个接口中,要调用另一个接口展示数据

a)         通过一个回调函数,

3,  Css,js文件打包

a)         Fis-confij.js文件中,

Pack:{    'static/util.js': [

                            "/static/js/mod.js",

                            "/static/js/jquery.js",

                          "/widget/header/header.js",

                            "/widget/otaNav/otaNav.js",

                          "/widget/log/log.js",

                                /\/static\/js\/(.*\.js)$/i

                      ], },

4,  编辑用户获取原本用户控制模块

a)         从接口查询原本可控制域,遍历之后,让相应模块选上

b)         选中父模块,子模块自动选上的实现,

进入时即设置isProTriggerClick为false

                            $(".block-nav").delegate(".parent-input",'click',function(e) {

                                     if ($(this).find(":input").prop("checked") || isProTriggerClick) {

                                               $(this).siblings().find(":input").prop("checked", true);

                                     } else {

                                               $(this).siblings().find(":input").prop("checked", false);

                                     }

                            });

                            $(".block-nav").delegate("label:not(.parent-input)",'click',function(e) {

                                     if (!$(this).find(":input").prop("checked") || isProTriggerClick) {

                                               $(this).siblings(".parent-input").find(":input").prop("checked", false);

                                     }

                            });

编辑用户,根据选择角色选择对应角色的控制模块

                            $(".block-nav").delegate('.role-nav','click',function () {

                                     var me = this, strpri, items;

                                     $(".parent-group [type=checkbox]").prop("checked", false);

                                     strrole = $('input[name="user-check"]:checked').val();

                                     //获取接口对应关系,选中角色,控制模块会自动全选

                                    

                                     $.each(user.Const.roleJsonUpdata.data, function () {

                                               if (this.id == strrole) {

                                                        strpri = this.module_list;

                                               }       

                                     });

                                     items = strpri.length ? strpri.split(",") : [];

                                     for(var i=0;i<items.length;i++){

                                               $('input[name="privilege-child-list"]').each(function () {

                                                        if($(this).val() == items[i]){

                                                                 $(this).prop("checked", true);

                                                        }

                                               });

                                               $('input[name="order-check-order"]').each(function () {

                                                        if($(this).val() == items[i]){

                                                                 $(this).prop("checked", true);

                                                        }

                                               });

                                     }

                            });

5,  接口请求的问题,同一种接口每个页面只请求一次

a)         将请求成功的json数据保存起来,放在一个全局对象中,下面再用到的时候直接使用而不是重新调用接口

6,  判断格式是否为邮箱格式

a)         /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(email)

posted on 2014-07-25 10:28  哈哈李小博  阅读(96)  评论(0编辑  收藏  举报