2012-04-09 19 views
5

を削除:完全に私はそうのようなTinyMCEのを初期化しているjQueryのTinyMCEの

$('#text').tinymce({ 
    // Location of TinyMCE script, optional, already loaded in page. 
    script_url : '../adminContent/js/tiny_mce/tiny_mce.js', 

    // General options 
    theme : "advanced", 
    plugins : "table,advimage,advlink,iespell,inlinepopups,preview,contextmenu,paste,visualchars", 

    // Theme options 
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,forecolor,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image", 
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,removeformat,cleanup,code,|,preview,tablecontrols,|,hr,visualaid,|,charmap,iespell", 
    theme_advanced_buttons3 : "", 

    theme_advanced_toolbar_location : "top", 
    theme_advanced_toolbar_align : "left", 
    theme_advanced_statusbar_location : "bottom", 
    theme_advanced_resizing : true 
}); 

上記のコードは完璧に動作します。問題は、私がtinyMCEを取り除こうとするときです。

マイ削除コードは次のとおりです。私も試した

$('#text').tinymce().execCommand('mceRemoveControl', false, 'text'); 

$('#text').remove(); 

$('#text').tinymce().remove(); 

最初のものは何もしていないようです。最後の二つは私に、このエラーを与える:

$.getScript(viewPath + '/mod/adminContent/js/editContent.js', function(){ 
    initEditContent(popup); 
}); 

ポップアップがTinyMCEのがロードされるポップアップへの参照です:TinyMCEのは、HTMLドキュメントによってロードされているが

Uncaught ReferenceError: t is not defined

は、私が使用して別のスクリプトをロードしています。これは単にjqueryを使って作成されたdivです。 divの内容は、jquery ajaxを使用してロードされます。

はeditContent.jsは、次のようになります。

var contentID; 
function initEditContent(popup){ 
    contentID = $('#contentID').val(); 

    tinyMCE.execCommand("mceAddControl", true, 'text'); 

    setTimeout(reposition, 50); 
    setTimeout(reposition, 150); 
    setTimeout(reposition, 250); 

    // Submit form 
    $('#editTextForm').ajaxForm(
    { 
     // Before submit 
     beforeSubmit: function(){ 
      //setPopupMessage(popup, '<div id="loading"><img src="../../img/loading.gif" />&nbsp;Please wait...</div>'); 
     }, 

     // Once submit completed 
     success: function(responseText){ 
      tinyMCE.execCommand("mceRemoveControl", true, 'text'); 
      //closePopup(popup); 

      // Update button with new data 
      $('#' + contentID).html(responseText); 
     } 
    }); 
} 
+0

'.tinymce()削除()'トリックを行う必要があります。問題が再現された[jsFiddle](http://jsfiddle.net)にテストケースを投稿できますか? – mekwall

+0

私は初期の質問を編集して詳細を教えてくれました。 jsFiddleを使用することはできません。必要な外部部品が多すぎるため、恐れがあります。 – JPardoe

+0

と呼ばれるtinyMCE.remove(); 「Uncaught TypeError:tiny_mce_src.jsの11264行の 'undefinedのID'プロパティを読み取れません。 – JPardoe

答えて

0

は、 'テキスト' は

<textarea id='text' ..... 
+0

しようとしたこと - 同じエラー: キャッチされないにReferenceError:tは私はTinyMCEのの_srcバージョンが含まれているとエラーが行12318に発生している に定義されていない。 '非表示:関数(){ \t \t \t VAR自己=これ、doc = t.getDoc(); キャッチされていないにReferenceError:tはIEが(isIE && DOC)場合、エディタ \t \t \tから左に点滅するカーソルを持って \t \t \t //バグを修正 \t \t \t \t doc.execCommand( 'のSelectAll')を定義されていません; \t \t \t //私たちはSafariが \t \t \t self.saveを()クラッシュしない隠す前に、私たちは、保存する必要があります。 \t \t \t DOM.hide(self.getContainer()); \t \t \t DOM.setStyle(self.id、 'display'、self.orgDisplay); \t \t}、 – JPardoe

1

問題が解決し、あなたのエディタのIDで

$('#text').tinymce().execCommand('mceRemoveControl', true, 'text'); 

を試してみてください。私はそれを初期化するために必要なときに興味を持っているものについては、私はその後、HTML文書にTinyMCEのをロードし、私がやった:

tinyMCE.init({ 
    mode : "textareas", 
    // General options 
    theme : "advanced", 
    plugins : "table,advimage,advlink,iespell,inlinepopups,preview,contextmenu,paste,visualchars", 

    // Theme options 
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,forecolor,|,justifyleft,justifycenter,justifyright,justifyfull,formatselect,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image", 
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,removeformat,cleanup,code,|,preview,tablecontrols,|,hr,visualaid,|,charmap,iespell", 
    theme_advanced_buttons3 : "", 

    theme_advanced_toolbar_location : "top", 
    theme_advanced_toolbar_align : "left", 
    theme_advanced_statusbar_location : "bottom", 
    theme_advanced_resizing : true, 

    oninit: function(){ 
     alert('tinyMCE loaded'); 
    } 
}); 

上記のコードはTinyMCEのエディタが必要とされるたびに呼び出されます。ポップアップを閉じたときに削除しました:

tinyMCE.remove('text'); 
4

これは、バージョン3.5b3以降のtinyMCEの問題のようです。バージョン3.5b2で動作します。

my fiddleを参照してください。

これは、読み込みと読み込みが正常に行われていることに気づくでしょう。しかし、バージョンをedgeまたは3.5b3に変更すると、アンロード時にエラーが発生します。 tinyMCE bug site上に述べたように

Description of problem:

Javascript error on line 13518. t is not defined.

Steps to reproduce:

  1. Call tinyMCE.execCommand('mceRemoveControl', false, idOfTextarea);

Problem:

In 3.5b3 you renamed t to self, but didn't rename the used variable in the same line to get the doc.

Solution:

Change line 13518 (in function hide()) to: var self = this, doc = self.getDoc();

+0

ありがとうございます。これは私の問題を解決しました。 –

関連する問題