[英]Data not fetch on CK Editor
我正在嘗試從數據庫綁定CK編輯器中的數據。 但它也無法正常工作,數據已獲取但無法顯示,僅在單擊Google Chrome中的檢查元素時顯示。
HTML
<textarea id="input" name="input"></textarea>
JS
<script>
$(document).ready(function () {
$("#input").ckeditor();
});
function BindData() {
$("#input").val('This is CK Editor Demo');
}
BindData();
</script>
Here
鏈接
首先,您必須等待DOM准備就緒,然后必須等待編輯器准備就緒,最后可以綁定數據:
// Wait for DOM to be ready.
$( document ).ready( function() {
// Create an instance of the editor.
$( '#input' ).ckeditor( function( textarea ) {
// When the instance is ready, set some data.
$( textarea ).val( 'This is CK Editor Demo!' );
} );
} );
或使用外部方法:
function BindData() {
$( '#input' ).val( 'This is CK Editor Demo!' );
}
// Wait for DOM to be ready.
$( document ).ready( function() {
// Create an instance of the editor.
$( '#input' ).ckeditor( function() {
// When the instance is ready, set some data.
BindData();
} );
} );
閱讀新版jQuery適配器的官方指南 (從4.2開始)。
您加載ckeditor,並在填充文本區域之后。 沒辦法,ckeditor已加載。 沒有實時更新。 您必須更改訂單。
<script>
function BindData() {
$("#input").val('This is CK Editor Demo');
}
BindData();
$(document).ready(function () {
$("#input").ckeditor();
});
</script>
您可以使用 :
CKEDITOR.instances[ckeditorname].setData(yourdata)
在ckeditor實例之后綁定數據
嘗試:
<script>
$(document).ready(function () {
$("#input").ckeditor();
BindData();
});
function BindData() {
CKEDITOR.instances["input"].setData('This is CK Editor Demo');
}
</script>
在ckeditor初始化之后調用BindData()
函數。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.