2017-04-10 123 views
0

我在TinyMCE中使用了豐富的HTML文本區域。我通過將HTML附加到DOM來動態添加一個或多個<textarea>標籤。每個<textarea>插入<li>標籤內。TinyMCE動態HTML值問題

如何使用jQuery獲取textarea的HTML ?.對於每個tinMCE HTML和BODY標籤在那裏

<html> 
 

 
<head> 
 
    <style id="mceDefaultStyles" type="text/css"> 
 
    .mce-content-body div.mce-resizehandle { 
 
     position: absolute; 
 
     border: 1px solid black; 
 
     box-sizing: box-sizing; 
 
     background: #FFF; 
 
     width: 7px; 
 
     height: 7px; 
 
     z-index: 10000 
 
    } 
 
    
 
    .mce-content-body .mce-resizehandle:hover { 
 
     background: #000 
 
    } 
 
    
 
    .mce-content-body img[data-mce-selected], 
 
    .mce-content-body hr[data-mce-selected] { 
 
     outline: 1px solid black; 
 
     resize: none 
 
    } 
 
    
 
    .mce-content-body .mce-clonedresizable { 
 
     position: absolute; 
 
     opacity: .5; 
 
     filter: alpha(opacity=50); 
 
     z-index: 10000 
 
    } 
 
    
 
    .mce-content-body .mce-resize-helper { 
 
     background: #555; 
 
     background: rgba(0, 0, 0, 0.75); 
 
     border-radius: 3px; 
 
     border: 1px; 
 
     color: white; 
 
     display: none; 
 
     font-family: sans-serif; 
 
     font-size: 12px; 
 
     white-space: nowrap; 
 
     line-height: 14px; 
 
     margin: 5px 10px; 
 
     padding: 5px; 
 
     position: absolute; 
 
     z-index: 10001 
 
    } 
 
    
 
    .mce-visual-caret { 
 
     position: absolute; 
 
     background-color: black; 
 
     background-color: currentcolor; 
 
    } 
 
    
 
    .mce-visual-caret-hidden { 
 
     display: none; 
 
    } 
 
    
 
    *[data-mce-caret] { 
 
     position: absolute; 
 
     left: -1000px; 
 
     right: auto; 
 
     top: 0; 
 
     margin: 0; 
 
     padding: 0; 
 
    } 
 
    
 
    .mce-content-body .mce-offscreen-selection { 
 
     position: absolute; 
 
     left: -9999999999px; 
 
     max-width: 1000000px; 
 
    } 
 
    
 
    .mce-content-body *[contentEditable=false] { 
 
     cursor: default; 
 
    } 
 
    
 
    .mce-content-body *[contentEditable=true] { 
 
     cursor: text; 
 
    } 
 
    
 
    img:-moz-broken { 
 
     -moz-force-broken-image-icon: 1; 
 
     min-width: 24px; 
 
     min-height: 24px 
 
    } 
 
    </style> 
 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
 
    <link type="text/css" rel="stylesheet" href="http://localhost:62993/Content/tinymce/skins/lightgray/content.min.css"> 
 
    <link type="text/css" rel="stylesheet" href="http://localhost:62993/News/css/example.css"> 
 
</head> 
 

 
<body id="tinymce" class="mce-content-body arn_richclass" data-id="txtID0" spellcheck="false" contenteditable="true"> 
 
    <p>Test<br data-mce-bogus="1"></p> 
 
</body> 
 

 
</html>

回答

1

,而你在TinyMCE的底層<textarea>工作沒有更新。如果您執行正常的HTML表單提交,TinyMCE將在提交過程開始時更新其textarea。如果你需要得到TinyMCE的更新其在其他任何時間基本<textarea>您可以撥打:

tinyMCE.triggerSave(); 

這將指示TinyMCE的情況下,可以把自己的當前狀態到底層<textarea>領域。然後,您可以像使用其他任何<textarea>那樣使用JavaScript與這些<textarea>域進行交互。