浏览 1248 次
|
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
时间:2008-03-12
在EXT中内置编辑器为FCKeditor时使用了下面的代码,出现错误,提示没有权限,经过反复测试,问题出现在下面的代码中,不知是何原因? 望高手们指点下,谢谢.
function FCKeditor_OnComplete(editorInstance){ Ext.getCmp(editorInstance.Name).MyisLoaded=true; Ext.getCmp(editorInstance.Name).setValue(Ext.getCmp(editorInstance.Name).value); } 具体代码如下: <script type="text/javascript" src="fckeditor/fckeditor.js"></script> <!-- Common Styles for the examples --> <link rel="stylesheet" type="text/css" href="../examples.css" /> <style type="text/css"> .x-panel-body p { margin:10px; } #container { padding:10px; } </style> </head> <body> <!--<script type="text/javascript" src="../examples.js"></script> <h1>Ext.Panel</h1> <p>The js is not minified so it is readable. See <a href="panels.js">panels.js</a>.</p> <div id="container"> </div>--> <script language="javascript"> var oFCKeditorOptions = { BasePath : 'fckeditor/', Config : { BaseHref : window.location, //SkinPath : 'fckeditor/editor/skins/office2003', ProcessHTMLEntities : true, ProcessNumericEntities : false, StartupShowBlocks : true, ToolbarCanCollapse : false }, ToolbarSet : 'Default' }; Ext.form.FCKeditor = function(config){ this.config = config; Ext.form.FCKeditor.superclass.constructor.call(this, config); this.FCKid=0; this.MyisLoaded=false; this.MyValue=''; }; Ext.extend(Ext.form.FCKeditor, Ext.form.TextArea, { onRender : function(ct, position){ if(!this.el){ this.defaultAutoCreate = { tag: "textarea", style:"width:100px;height:60px;", autocomplete: "off" }; } Ext.form.TextArea.superclass.onRender.call(this, ct, position); if(this.grow){ this.textSizeEl = Ext.DomHelper.append(document.body, { tag: "pre", cls: "x-form-grow-sizer" }); if(this.preventScrollbars){ this.el.setStyle("overflow", "hidden"); } this.el.setHeight(this.growMin); } if (this.FCKid==0) this.FCKid=get_FCKeditor_id_value() setTimeout("loadFCKeditor('"+this.name+"',"+ this.config.height +","+this.config.width+");",100); }, setValue : function(value){ this.MyValue=value; if (this.FCKid==0) this.FCKid=get_FCKeditor_id_value(); FCKeditorSetValue(this.FCKid,this.name,value); Ext.form.TextArea.superclass.setValue.apply(this,[value]); }, getValue : function(){ if (this.MyisLoaded){ value=FCKeditorGetValue(this.name); Ext.form.TextArea.superclass.setValue.apply(this,[value]); return Ext.form.TextArea.superclass.getValue(this); }else{ return this.MyValue; } }, getRawValue : function(){ if (this.MyisLoaded){ value=FCKeditorGetValue(this.name); Ext.form.TextArea.superclass.setRawValue.apply(this,[value]); return Ext.form.TextArea.superclass.getRawValue(this); }else{ return this.MyValue; } } }); Ext.reg('fckeditor', Ext.form.FCKeditor); function loadFCKeditor(element,height,width){ alert(oFCKeditorOptions.BasePath); oFCKeditor = new FCKeditor(element); oFCKeditor.BasePath = oFCKeditorOptions.BasePath; oFCKeditor.ToolbarSet = oFCKeditorOptions.ToolbarSet; oFCKeditor.Config = oFCKeditorOptions.Config; oFCKeditor.Height = height; oFCKeditor.Width = width; oFCKeditor.Config['LinkBrowser'] = true ; oFCKeditor.Config['ImageBrowser'] = true ; oFCKeditor.Config['FlashBrowser'] = true ; oFCKeditor.Config['LinkUpload'] = true ; oFCKeditor.Config['ImageUpload'] = true ; oFCKeditor.Config['FlashUpload'] = true ; oFCKeditor.ReplaceTextarea(); } function FCKeditor_OnComplete(editorInstance){ Ext.getCmp(editorInstance.Name).MyisLoaded=true; editorInstance.Events.AttachEvent('OnStatusChange', function(){ Ext.getCmp(editorInstance.Name).setValue(); }) ; } var FCKeditor_value=new Array(); function FCKeditorSetValue(id,name,value){ if ((id!=undefined)&&(name!=undefined)){ if (value!=undefined) FCKeditor_value[id]=value; else if (FCKeditor_value[id]==undefined) FCKeditor_value[id]=''; var oEditor = FCKeditorAPI.GetInstance(name); if(oEditor != undefined) oEditor.SetData(FCKeditor_value[id]); } } function FCKeditorGetValue(name){ if ((id!=undefined)&&(name!=undefined)){ var oEditor = FCKeditorAPI.GetInstance(name) ; data=''; if(oEditor!=undefined) data=oEditor.GetData(); return data; } } var FCKeditor_id_value; function get_FCKeditor_id_value(){ if (!FCKeditor_id_value){ FCKeditor_id_value=0; } FCKeditor_id_value=FCKeditor_id_value+1; return FCKeditor_id_value; } Ext.onReady(function(){ var form= new Ext.form.FormPanel({ labelAlign : 'right', method : 'GET', height : 700, width : 900 , buttonAlign : 'center', labelWidth : 80, frame : true, defaultType : 'textfield', items : [{ name : 'alarmCode', width : 450, fieldLabel : 'Alarm Code' },{ name : 'alarmText', width : 450, fieldLabel : 'Alarm Text' },{ xtype : 'fckeditor', name : 'documentBody', id : 'documentBody', fieldLabel : 'Document', height : 300, width : 550 } ] }); form.render(document.body); }); </script> 声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
|
| 返回顶楼 | |
|
时间:2008-03-12
一样阿,我的也是,没有找到原因。
|
|
| 返回顶楼 | |
|
时间:2008-03-12
根据我模糊的回忆,这个问题发生在FCKeditor没有初始化完毕时,如果你对这个editor进行操作,就会出现这个问题
|
|
| 返回顶楼 | |
|
时间:2008-03-12
@yeaha
是啊,那有什么办法解决呢? |
|
| 返回顶楼 | |
|
时间:2008-03-12
调整你的代码执行步骤,没其它办法,just hack it
|
|
| 返回顶楼 | |
|
时间:2008-03-12
yeaha 写道 调整你的代码执行步骤,没其它办法,just hack it
详细说说如何 |
|
| 返回顶楼 | |
|
时间:2008-03-13
请参考我写好的例子:http://www.javaeye.com/topic/170998
|
|
| 返回顶楼 | |
|
时间:2008-03-14
@dengddq
谢谢了,我会去试试看. |
|
| 返回顶楼 | |
|
时间:2008-03-15
我也遇到这个问题
前面几位谁解决了能说明一下吗? 谢了 |
|
| 返回顶楼 | |





