2012-04-12 96 views
0

當雙擊該行或者單擊「編輯」按鈕並選擇一行時,我通過數據行中的數據填充YUI RTE。 IE和FF的執行效果與預期的一樣,但Chrome填充了html內容(我通過在chrome的檢查el功能中進行調試瞭解到這一點),然後幾毫秒後它就會將其擦除。有什麼建議麼??YUI 2.9.0 Chrome中的富文本編輯器填充,然後刪除編輯器HTML

這裏是我如何構建YUI RTE

function CreateRTE() { 

    //create the RTE: 
    emailEditor = new YAHOO.widget.Editor('txtEmlBody', { width: '468px', height: '200px' }); 

    //After the Editor renders it, we will hide it so the iframe doesn't bleed through 
    emailEditor.on('afterRender', emailEditor.hide); 

    //Add the insert token button when the toolbar is loaded 
    emailEditor.on('toolbarLoaded', function() { 

     //Create the button configuration 
     var config = { type: 'menu', label: 'Insert Token', value: 'inserttoken', menu: tokenMenu }; 

     //Add the button to the toolbar 
     emailEditor.toolbar.addButtonToGroup(config, 'insertitem'); 

     //Add the event handler for a menu item click 
     emailEditor.toolbar.on('inserttokenClick', function (ev) { this.execCommand('inserthtml', ev.button.value); }, emailEditor, true); 

    }); 

    //render the editor explicitly into a container within the Dialog's DOM: 
    emailEditor.render(); 


} 

這裏就是我如何填充RTE當行被雙擊或者選擇一個行單擊編輯按鈕。

function EditEmail() { 

    //Get the record from the datatable 
    var dt = grids.tblEmails.dataTable; 
    var tr = dt.getSelectedRows()[0]; 
    var row = dt.getRecord(tr); 

    //Populate the form 
    YAHOO.util.Dom.get('hidEmlId').value = row.getData('ID'); 
    YAHOO.util.Dom.get('hidEmlType').value = row.getData('Type'); 
    YAHOO.util.Dom.get('txtEmlSubject').value = row.getData('Title'); 

    emailEditor.setEditorHTML(row.getData('Body')); 

    //Show the dialog 
    dialogs.dlgEmail.show(); 

} 

我的確看過this這篇文章,但是這個問題似乎並不符合。 HTML編輯器的上下文正在填充,然後刪除.... sooo,任何幫助將非常感激。

回答

2

嘗試在設置編輯器的html (emailEditor.setEditorHTML(row.getData('Body'));)之前使用html (row.getData('Body')),更新編輯器的支持文本區域。這應該允許它在Chrome/Safari中工作。

+1

你是個天才。謝謝。 – wakurth 2012-04-13 14:24:12