【发布时间】:2011-11-05 01:35:20
【问题描述】:
我想获取tinymce textarea的值
<textarea id="thetextarea"></textarea>
打开键以便将其输入到显示预览脚本中,使用:
function showPreview(value) {
$("#preview-container").load("/material-preview.php", {s:value});
}
$('thetextarea').live("keyup",function (e) {
var material = this.value;
showPreview(material);
return false;
});
如果我尝试选择 textarea id thetextarea 它不起作用(如果我不将其设为 tinymce 字段则有效)。
使用萤火虫我看到文本,当 textarea 被 tinymce-converted 时,在:
<body id="tinymce" class="mceContentBody"></body>
但这也不起作用,($('#tinymce') 也不起作用)
$('mceContentBody').live("keyup",function (e) {
var material = this.value;
showPreview(material);
return false;
});
根据要求应用 tinyMCE 后的 HTML 代码(来自 firebug)
<textarea id="material-input" class="mceEditor text" style="width: 310px ! important; height: 250px ! important; display: none;" name="material" aria-hidden="true"></textarea>
<span id="material-input_parent" class="mceEditor defaultSkin" role="application" aria-labelledby="material-input_voice">
<span id="material-input_voice" class="mceVoiceLabel" style="display:none;">Rich Text Area</span>
<table id="material-input_tbl" class="mceLayout" cellspacing="0" cellpadding="0" role="presentation" style="width: 310px; height: 250px;">
<tbody>
<tr class="mceFirst" role="presentation">
<tr>
<td class="mceIframeContainer mceFirst mceLast">
<iframe id="material-input_ifr" frameborder="0" src="javascript:""" allowtransparency="true" title="Rich Text Area. Press ALT F10 for toolbar. Press ALT 0 for help." style="width: 100%; height: 206px;">
<html>
<head xmlns="http://www.w3.org/1999/xhtml">
<body id="tinymce" class="mceContentBody " contenteditable="true" spellcheck="false" dir="ltr">
<!-- the text inside tinymce textarea -->
</body>
</iframe>
</td>
</tr>
<tr class="mceLast">
</tbody>
</table>
</span>
【问题讨论】:
-
在stackoverflow.com/questions/1024712/…的帮助下解决了这个问题