[轉]ExtJs裏使用FckEditor

 

原貼見:

http://ext.group.javaeye.com/group/post/37548

http://extjs.com/forum/showthread.php?t=17423

Ext.onReady(function() {   
 
var fckFormObj = new Ext.FormPanel({   
  labelWidth:
75,   
  url:
"",   
  title:
"EXT/FCKEditor 集成 -- vb2005xu | cdlinux.ys168.com",   
  bodyStyle:
"padding:5px 5px 0",   
  defaultType:
"form",   
  buttons:[   
   {   
    text:
"Save" ,   
    type:
'submit',   
    handler: 
function(){   
     
//獲取fckeditor內容賦給textarea   
     Ext.get('fckInstance').dom.value = "jjj";//fckobj.GetXHTML(true) + '提交後';     
     Ext.MessageBox.alert('FCK內容',Ext.get('fckInstance').dom.value);   
     
if (fckFormObj.form.isValid())   
     {   
      
//創建響應測試函數         
      var fckobj_temp = FCKeditorAPI.GetInstance('fckInstance');   
      
//fckobj_temp.UpdateLinkedField();//此方法被綁定到submit事件   
         
      fckFormObj.form.doAction(
'submit',{   
       url:
'submit.php',   
       method:
'post',   
       waitMsg:
'正在提交,請稍等',   
        success:
function(form,action){//成功   
         showInfo('Success',fckobj_temp.GetXHTML(true));   
        } ,   
        failure:
function(form,action){//失敗   
         showInfo('Failed','網絡中斷造成連接失敗');   
        }   
      });   
     }   
    }   
   },   
   {   
    text:
"Cancel"  
   }   
  ],   
  items:[{   
      xtype:
"textarea",   
      fieldLabel:
"編輯",   
      labelSeparator:
"",   
      id:
"fckInstance"//div節點,這裏要掛接FCKeditor編輯器   
      name:"fckInstance",   
      width:
736,   
      height:
371  
  }]   
 });   
 fckFormObj.render(document.body);   
    
 
/*創建Fckeditor對象 -- 構造函數指出了Fckeditor要掛接的id,上文中的xtype : 'textarea'指定*/  
 
//在頁面上要求掛載fckeditor/fckeditor.js文件   
 var fckobj = new FCKeditor('fckInstance',810,350);   
 fckobj.BasePath 
= "/ucren/fckeditor/" ;   
 fckobj.ToolbarSet 
= 'Default' ;   
 fckobj.ReplaceTextarea();    
    
 
//創建響應測試函數   
 function msgBox()   
 {   
  
var fckobj_temp = FCKeditorAPI.GetInstance('fckInstance');   
  fckobj_temp.UpdateLinkedField();
//此方法被綁定到submit事件   
  Ext.MessageBox.alert('FCK內容',fckobj_temp.GetXHTML( true ));   
     
 }   
    
 
function showInfo(tip,str){   
  
var win = new Ext.Window({   
   title: 
'信息提交應答提示 -- ' + tip,   
   width: 
400 , height: 200 ,autoScroll: true ,   
   html: 
'<h1>'+ str +'</h1>'       
  });   
  win.show();   
 }   
});  
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章