jquery dialog kindeditor

主页面 <a class="button" id="J_openDialog" href="/jsp/ballsBoy/bussiness/add.jsp" onclick="javascript:void(0);">添加</a> 
js $(this).find('#J_openDialog').click($.onKindEditor);绑定事件
打开窗口
$.onKindEditor = function() {
          var dialogTitle = this.title ? this.title : $(this).html();
          $('#indicator').show();
          $.get(this.href,function(htmlData) {
              $('#indicator').hide();
              htmlData = "<div>" + htmlData + "</div>"
              var dialogInnerHtml = $(htmlData).find('form');
              var dialogWidth = dialogInnerHtml.attr('width')? dialogInnerHtml.attr('width'):'auto';
              var dialogHeight = dialogInnerHtml.attr('height')? dialogInnerHtml.attr('height'):'auto';
              var dialogTop = dialogInnerHtml.attr('top')? dialogInnerHtml.attr('top'):'auto';
              var dialog = $.openKindDialog(dialogTitle,htmlData,dialogWidth,dialogHeight,dialogTop);
              if(!opens)
              opens=dialog;          
              dialog.enhanceUIElements();
          });
          return false;
        }
    $.openKindDialog = function(title,htmlData,width,height,top,left) {
         var dialogDiv = '<div class="common-form"></div>';
         var dialogInstance = $(dialogDiv).appendTo($(document)).dialog({
             modal: false,
             title: title,
             height: height,
             width: width,
             minWidth:250,
             minHeight:150,
             autoOpen :false,
             resizable:false,
             show: 'scale',
             hide: 'scale',
             // 修改对话框弹出位置
             position: ['auto', parseInt(top)],
             close: function(){
                 dialogInstance.dialog('destroy');
                 dialogInstance.remove();
             }
         });
         dialogInstance.append(htmlData);
         dialogInstance.find('.btn-cancel').click(function(){
             dialogInstance.dialog('close');
         });
         return dialogInstance;
    }    
打开页面初始化editor
<script>
$('#J_editorDialog').dialog({
    title : '商务信息',
    width : 700,
    open : function(event, ui) {
        // 打开Dialog后创建编辑器
        KindEditor.create('#kindeditor', {
            resizeType : 1
        });
    },
    beforeClose : function(event, ui) {
        // 关闭Dialog前移除编辑器
        KindEditor.remove('#kindeditor');
    }
});
</script>
 

 

posted @ 2014-11-28 08:55  流氓剑客  阅读(256)  评论(0)    收藏  举报