当前位置: 代码迷 >> JavaScript >> extjs fckeditor form submit 获取值解决方法
  详细解决方案

extjs fckeditor form submit 获取值解决方法

热度:477   发布时间:2012-11-22 00:16:41.0
extjs fckeditor form submit 获取值解决办法
Ext.onReady(function(){   
var fckeditorFormPanel = new Ext.FormPanel({   
        labelWidth: 75,    
        url:'',   
        frame:true,   
        title: 'fckeditor Form',   
        bodyStyle:'padding:5px 5px 0',   
        width: 950,   
        height:450,   
        defaultType: 'textfield',   
  
        items: [{   
                    xtype:'textarea',   
                    fieldLabel:'编辑',   
                    labelSeparator:':',   
                    id:'code',   
                    name:'code',   
                    height:200,   
                    width:300  
                }   
        ],   
        buttons: [{   
            text: 'Save'  
        },{   
            text: 'Cancel'  
        }]   
    });     
    fckeditorFormPanel.render(document.body);   
    /**  
         * 以下创建在线编辑器  
         */  
    var oFCKeditor = new FCKeditor( 'code',810,350 ) ;    
    oFCKeditor.BasePath = "/fckeditor/" ;    
    oFCKeditor.ToolbarSet = 'Default';   
    oFCKeditor.ReplaceTextarea() ;       
}); 
// 对获不到值,使用下面的代码可以获到值


Ext.onReady(function(){   
var fckeditorFormPanel = new Ext.FormPanel({   
        labelWidth: 75,    
        url:'',   
        frame:true,   
        title: 'fckeditor Form',   
        bodyStyle:'padding:5px 5px 0',   
        width: 950,   
        height:450,   
        defaultType: 'textfield',   
  
        items: [{   
                    xtype:'textarea',   
                    fieldLabel:'编辑',   
                    labelSeparator:':',   
                    id:'code',   
                    name:'code',   
                    height:200,   
                    width:300  
                }   
        ],   
        buttons: [{   
            text: 'Save',   
            type:'submit',   
            handler: function() {   
                Ext.get('code').dom.value=editorInstance.GetXHTML( true );//获取fckeditor内容赋给textarea   
                alert(Ext.get('code').dom.value);   
                if(fckeditorFormPanel.form.isValid()){//验证通过   
                    fckeditorFormPanel.form.doAction('submit',{   
                          url:'submit.do',   
                          method:'post',   
                          waitMsg:'正在提交,请稍等...',   
                          success:function(form,action){//成功返回     
                                   
                          },   
                          failure:function(form,action){//失败返回   
                                 
                          }   
                    });   
                }   
            }   
        },{   
            text: 'Cancel'  
        }]   
    });     
    fckeditorFormPanel.render(document.body);   
    /**  
         * 以下创建在线编辑器  
         */  
    var oFCKeditor = new FCKeditor( 'code',810,350 ) ;    
    oFCKeditor.BasePath = "/fckeditor/" ;    
    oFCKeditor.ToolbarSet = 'Default';   
    oFCKeditor.ReplaceTextarea() ;   
});   
var editorInstance;   
/**  
* FCKEditor初始化完成将调用此方法  
* @param {Object} editorInstance  
*/  
function FCKeditor_OnComplete( instance ) {   
    editorInstance=instance;   
}; 
  相关解决方案