2017-11-23 8 views
0

ここの質問によると、Can codemirror be used on multiple textareas?です。codemirror - 複数のテキスト領域が機能しない

自分のページに正確な設定を適用しましたが、どちらのテキストエリアもコードミラーに変換されていません。

コンソールにもエラーはありません。どちらが欲しいのか分かりませんか?次のように

私のコードは次のとおりです。

<script src="{% static 'home/scripts/codemirror/codemirror.js' %}"></script> 
<link href="{% static 'home/scripts/codemirror/codemirror.css' %}" rel="stylesheet"> 
<script src="{% static 'home/scripts/codemirror/django/django.js' %}"></script> 
<script type="text/javascript"> 
function editor(id) { 
     CodeMirror.fromTextArea(id, { 
      height: "400px", 
      continuousScanning: 500, 
      lineNumbers: true 
     }); 
    } 
editor('id_config'); 
editor('id_remote_config'); 
</script> 
<form id="edit_template" action="" method="post"> 
    {% csrf_token %} 
    {{ TemplateForm.template_name }} 
    {{ TemplateForm.config }} 
    {{ TemplateForm.remote_config }} 
    <input type='submit' value='Update' /> 
</form> 

Djangoのフォームは、私は誰もが任意のアイデアを持っている

text area ids

を指定したIDを持つテキスト領域をレンダリング? ありがとう

答えて

1

editor()に電話をかけた時点では、これらのテキストエリアは存在しません。フォームの下にスクリプトタグを移動するか、ウィンドウロードイベントハンドラ内でeditor()を呼び出してください

+0

のフォームの下のすべてをまだ移動していませんか? – AlexW

+0

ブラウザのコンソールにエラーがありますか? – charlietfl

+0

TypeError:textarea.getAttributeは関数ではありません。 ( 'textarea.getAttribute( "autofocus")'、 'textarea.getAttribute'は未定義です) - codemirror 9512 – AlexW

関連する問題