1

html を一連のテキストエリアにロードし、display:none; のスタイルを指定します。次に、各テキストエリアの ID 属性の値を保持するオプションを含む素敵なドロップダウン メニューを用意します。

ドロップダウンの変更をリッスンするjqueryがあり、IDが検出されると、対応するテキストエリアの値を素敵なTinyMCEプラグインを使用してプライマリテキストエリアにロードします。

TinyMCE がなくても、すべて正常に動作します。しかし、エディターは動的にロードされた html テキストを表示しません。

誰かが私が間違っていることを見ることができますか?

コード:

<textarea id="template1"><div>Some html <b>inside this textarea</b><br>And more</textarea>
<textarea id="template2"><div>More html <b>inside this textarea</b><br>And more</textarea>

<select name="templateid" id="templateid"> 
  <option value="0">-------------</option>
  <option value="1">Load Template 1</option>
  <option value="2">Load Template 2</option>
</select>

<textarea id="maintemplate"></textarea>

<script language="javascript" type="text/javascript">
$(document).ready(function(){

$("#templateid").change(function(){ 
    var templateid = $(this).val();
    if(templateid == 0){ $("#templatetext").val(""); return false; }
    var html = $("#template"+templateid).val();
    $("#maintemplate").val(html); // this is ignored?
    return false;   
});


$("textarea#maintemplate").tinymce({
    script_url : '/includes/modules/tiny_mce/tiny_mce.js',// Location of TinyMCE script
    // General options
    theme : "advanced",
    plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",
    force_p_newlines : false,
    force_br_newlines : true,
    /*forced_root_block : '',*/
    // Theme options
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleprops,forecolor,backcolor,|,link,unlink,image,|,bullist,numlist,removeformat,code,|,cleanup,preview",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_buttons4 : "",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : true,
});

});
</script>

ご覧のとおり$("#maintemplate").val(html);、他のテキストエリアの値をロードしている場所です。しかし、エディターはそれを表示していません。(エディタがなくても動作します)

4

1 に答える 1

1

誰かが私が間違っていることを見ることができますか?

これがあなたのコードの動作デモです(そのまま貼り付けられます)....

私が指摘できる唯一のことは、あなたがロードしていないということです

<script type="text/javascript" src="../jscripts/tiny_mce/jquery.tinymce.js"></script>

それが役に立てば幸い!!!

于 2013-01-22T07:32:08.947 に答える