`
xylong
  • 浏览: 187561 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

闭包收录(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 class="ui-icon ui-icon-alert" 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);
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics