Ueditor是由百度開發的一個開源的富文本編輯器,有人作了一個將其集成到Django中的方案(請戳),可是在xadmin中卻沒法正常加載編輯器。javascript
其使用了一個模板用來呈現Ueditor的編輯界面css
<textarea name={{ UEditor.name }} id=id_{{ UEditor.name }} style="display:inline-block;width:{{ UEditor.width }}px; {{ UEditor.css }}">{{UEditor.value}}</textarea> <script type="text/javascript"> var id_{{ UEditor.name }}= new baidu.editor.ui.Editor({ "UEDITOR_HOME_URL":"{{ STATIC_URL }}ueditor/", {% ifnotequal UEditor.toolbars None %}"toolbars":{{ UEditor.toolbars|safe }} ,{% endifnotequal %} "imageUrl":"/ueditor/ImageUp/{{ UEditor.imagePath }}", "imagePath":"{{ MEDIA_URL }}{{ UEditor.imagePath }}", "scrawlUrl":"/ueditor/scrawlUp/{{ UEditor.scrawlPath }}", "scrawlPath":"{{ MEDIA_URL }}{{ UEditor.scrawlPath }}", "imageManagerUrl":"/ueditor/ImageManager/{{ UEditor.imageManagerPath }}", "imageManagerPath":"{{ MEDIA_URL }}{{ UEditor.imageManagerPath }}", "catcherUrl":"/ueditor/RemoteCatchImage/{{ UEditor.imagePath }}", "catcherPath":"{{ MEDIA_URL }}{{ UEditor.imagePath }}", "fileUrl":"/ueditor/FileUp/{{ UEditor.filePath }}", "filePath":"{{ MEDIA_URL }}{{ UEditor.filePath }}", "getMovieUrl":"/ueditor/SearchMovie/" {% ifnotequal UEditor.options '' %},{{ UEditor.options|safe }}{% endifnotequal %} }); id_{{UEditor.name}}.render('id_{{ UEditor.name }}'); id_{{UEditor.name}}.addListener('ready',function(){ id_{{UEditor.name}}.setHeight({{ UEditor.height }}); }); </script>
我發如今xadmin中是能夠正常加載這段模板的,因而懷疑是不是js的問題,所以在script中加入了幾個alert,結果發如今java
id_{{UEditor.name}}.render('id_{{ UEditor.name }}');
以後的alert沒有彈出,倒是是由於js加載的問題。git
所以可能的緣由是在class Media中聲明的靜態文件加載順序比較靠後,致使Ueditor的js代碼沒法執行,因此我在上面那段模板中加入了github
<script type="text/javascript" src="/static/ueditor/editor_config.js"></script> <script type="text/javascript" src="/static/ueditor/editor_all_min.js"></script>
而後ueditor就能夠正常工做了。編輯器