Tôi muốn nhận được giá trị của một textarea TinyMCEgiá trị Nhận của TinyMCE textarea với selector jquery
<textarea id="thetextarea"></textarea>
trên chìa khóa lên để nuôi nó thành một kịch bản show-preview sử dụng:
function showPreview(value) {
$("#preview-container").load("/material-preview.php", {s:value});
}
$('thetextarea').live("keyup",function (e) {
var material = this.value;
showPreview(material);
return false;
});
Nếu tôi cố gắng chọn id văn bản thetextarea
nó không hoạt động (hoạt động nếu tôi không làm cho nó một trường tinymce).
với firebug tôi thấy rằng các văn bản, khi textarea là TinyMCE-chuyển đổi, là:
<body id="tinymce" class="mceContentBody"></body>
nhưng điều này không làm việc, hoặc, (cũng không $('#tinymce')
)
$('mceContentBody').live("keyup",function (e) {
var material = this.value;
showPreview(material);
return false;
});
HTML mã (từ firebug) sau tinyMCE được áp dụng theo yêu cầu
<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>
Giải quyết nó với sự giúp đỡ của http://stackoverflow.com/questions/1024712/this-keyup-not-responding-when-focused-on-tinymce – Joseph