首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

闭包收录(一)

2012-07-08 
闭包收录(1)(function(w){//经典闭包//定义一个对象,类似java中的类,有方法,有属性var RCP (function(){

闭包收录(1)
(function(w){   //经典闭包
   
//定义一个对象,类似java中的类,有方法,有属性
      var RCP = (function(){
     
        var CONT_CLS = '.J_RcpCatList',
               CONT_RULES = '.J_RuleSlideList',
               CONT_FORM = '.J_RuleFormCont',
               CONT_NEWRULE = '.J_NewRuleCont',
               BTN_SUBMIT = '.J_RuleSubmit',
               BTN_EDIT = '.J_RuleEdit',
               URI_RULEFORM = '../api/ruleform.php';
       
//表单渲染
        function formRender(){
            bindCheck();
            bindFolder();
            bindSlide();
            createRule();
            bindFormEdit();
            bindFormDelete();
            refreshStates();
        }

        function bindFormEdit(){
           
            $(document).delegate(BTN_EDIT, 'click', function(){
                var theForm = $(this).parents('form:eq(0)');
                theForm.submit();
            })
           
        }
       
        function bindFormDelete(){
            $(document).delegate( '.J_RuleDelete', 'click', function(){
                var self = this;
                $( '<div title="删除规则"><p style="padding-top:14px;"><span style="float:left; margin:0 7px 7px 0;"></span>你确定要删除此规则?</p></div>' ).dialog({
                    resizable: false,
                    height:140,
                    modal: true,
                    buttons: {
                        "确定": function() {
                            $( this ).dialog( "close" );
                            var theForm = $(self).parents('form:eq(0)');
                            theForm.submit();
                        },
                        "取消": function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
            })
           
        }
       
        function init(){

        }
       
//对外开放关于RCP的两个方法
        return {
            create: createRule,
            render:formRender
        }
       
       
    })();
   
    w.RCP = RCP;
   
})(window);

热点排行