1

我在我的Django应用程序中使用django-tinymceHTML5 Boilerplate (H5BP) 。根据 H5BP 的明智建议,我已将jQuery负载放在身体底部。我将 TinyMCE 编辑器附加到我的表单字段,如下所示:

    widgets = {
        'content': TinyMCE(attrs={'cols': 40, 'rows': 15}),
    }

不幸的是,django-tinymce 在加载 jQuery 之前尝试通过附加到我的表单和表单集的标签来访问 jQuery。

有没有办法让 django-tinymce 在页面底部加载时与 jQuery 一起玩得很好?我宁愿不必在页面呈现之前加载脚本。

这是一个示例表格行:

<td>
<textarea rows="15" cols="40" name="form-0-content" id="id_form-0-content"></textarea>
<script type="text/javascript">tinyMCE.init({"spellchecker_languages": "Arabic=ar,Azerbaijani=az,Bulgarian=bg,Bengali=bn,Bosnian=bs,Catalan=ca,Czech=cs,Welsh=cy,Danish=da,German=de,Greek=el,+English / British English=en,Esperanto=eo,Spanish / Argentinian Spanish / Mexican Spanish / Nicaraguan Spanish=es,Estonian=et,Basque=eu,Persian=fa,Finnish=fi,French=fr,Frisian=fy,Irish=ga,Galician=gl,Hebrew=he,Hindi=hi,Croatian=hr,Hungarian=hu,Indonesian=id,Icelandic=is,Italian=it,Japanese=ja,Georgian=ka,Kazakh=kk,Khmer=km,Kannada=kn,Korean=ko,Lithuanian=lt,Latvian=lv,Macedonian=mk,Malayalam=ml,Mongolian=mn,Norwegian Bokmal=nb,Nepali=ne,Dutch=nl,Norwegian Nynorsk=nn,Punjabi=pa,Polish=pl,Portuguese / Brazilian Portuguese=pt,Romanian=ro,Russian=ru,Slovak=sk,Slovenian=sl,Albanian=sq,Serbian / Serbian Latin=sr,Swedish=sv,Swahili=sw,Tamil=ta,Telugu=te,Thai=th,Turkish=tr,Tatar=tt,Ukrainian=uk,Urdu=ur,Vietnamese=vi,Simplified Chinese / Traditional Chinese=zh", "elements": "id_form-0-content", "theme_advanced_buttons3": "forecolorpicker,fontselect,fontsizeselect", "custom_undo_redo_levels": 10, "skin": "o2k7", "cleanup_on_startup": true, "language": "en", "theme_advanced_buttons1": "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect", "directionality": "ltr", "theme_advanced_buttons2": "bullist,numlist,|,outdent,indent,|,undo,redo,|,hr", "theme": "advanced", "strict_loading_mode": 1, "mode": "exact"})</script>
</td>
4

1 回答 1

0

只需将您tinyMCE.init({...})放在 jQuery 的 'onDocumentReady' 中:

$(function() {
    tinyMCE.init({"spellchecker_languages": "Arabic=ar,Azerbaijani=az,Bulgarian=bg,Bengali=bn,Bosnian=bs,Catalan=ca,Czech=cs,Welsh=cy,Danish=da,German=de,Greek=el,+English / British English=en,Esperanto=eo,Spanish / Argentinian Spanish / Mexican Spanish / Nicaraguan Spanish=es,Estonian=et,Basque=eu,Persian=fa,Finnish=fi,French=fr,Frisian=fy,Irish=ga,Galician=gl,Hebrew=he,Hindi=hi,Croatian=hr,Hungarian=hu,Indonesian=id,Icelandic=is,Italian=it,Japanese=ja,Georgian=ka,Kazakh=kk,Khmer=km,Kannada=kn,Korean=ko,Lithuanian=lt,Latvian=lv,Macedonian=mk,Malayalam=ml,Mongolian=mn,Norwegian Bokmal=nb,Nepali=ne,Dutch=nl,Norwegian Nynorsk=nn,Punjabi=pa,Polish=pl,Portuguese / Brazilian Portuguese=pt,Romanian=ro,Russian=ru,Slovak=sk,Slovenian=sl,Albanian=sq,Serbian / Serbian Latin=sr,Swedish=sv,Swahili=sw,Tamil=ta,Telugu=te,Thai=th,Turkish=tr,Tatar=tt,Ukrainian=uk,Urdu=ur,Vietnamese=vi,Simplified Chinese / Traditional Chinese=zh", "elements": "id_form-0-content", "theme_advanced_buttons3": "forecolorpicker,fontselect,fontsizeselect", "custom_undo_redo_levels": 10, "skin": "o2k7", "cleanup_on_startup": true, "language": "en", "theme_advanced_buttons1": "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect", "directionality": "ltr", "theme_advanced_buttons2": "bullist,numlist,|,outdent,indent,|,undo,redo,|,hr", "theme": "advanced", "strict_loading_mode": 1, "mode": "exact"})
});
于 2015-07-28T20:48:58.780 回答