好的,我有一個div,當你點擊div時,我插入一個textarea,然後將tinyMCE controll添加到該textarea。好的,然後你輸入wsgi編輯器並按保存來保存它。TinyMCE Interst現有的HTML
然後html格式的tinyMCE編輯器被保存,並且textarea和tinyMCE元素被刪除,並且tinyMCE中的html被再次插入到div中。
這很好,現在,當我點擊div時,使用HTML,我希望該HTML顯示在tunyMCE編輯器內部。
這就是我所做的,但是一旦我點擊div,它會添加html,然後刪除它,爲什麼會發生這種情況?
// Click on the div element
$(".editable").live("click", function(e){
var f = $(this);
// get the html if it is there
html = f.html();
// insert a textarea with a unique id
f.html('<textarea class="item_html" id="'+ e.timeStamp +'"></textarea> ')
f.css("height","100%")
//add tinyMCE control to the textarea
tinyMCE.execCommand(
'mceAddControl',
false,
f.find("textarea").attr("id")
);
// if there was html insode the div clicked on, add it into the editor
tinyMCE.execCommand(
'mceInsertContent',
false,
html
);
});
你能爲此創建一個小提琴嗎? (http://jsfiddle.net) – Thariama
這裏你去http://jsfiddle.net/M3gNm/3/ – Harry
點擊div元素 – Harry