How to completely destroy the mud?

I am working on something like this:

On the web page there is an article wrapped in a DIV, the "Edit" button. When the user clicks the "Edit" button, paste the text field through javascript, load the html DIV into the text field, load and the initial tinment. When the user clicks the Save button, save and update the article using ajax and completely destroy tinymce.

The problem is that I could not destroy tinymce. Here is the destruction method document .

I am using jQuery version of tinymce, the latest version of V3.2.2

Here is a sample code:

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="../js/tinymce/jquery.tinymce.js"></script> <script type="text/javascript"> $(function() { $('button.load').click(loadTinyMCE); $('button.destory').click(destoryTinyMCE); }); function loadTinyMCE() { $('textarea').tinymce({ script_url : '../js/tinymce/tiny_mce.js' }); } function destoryTinyMCE() { $('textarea').tinymce().destroy(); } </script> </head> <body> <textarea>abc</textarea> <button type="button" class="load">Load TinyMCE</button> <button type="button" class="destory">Destory TinyMCE</button> </body> </html> 
+7
javascript tinymce
source share
4 answers

Use remove () instead.

+9
source share

You already have a practical decision made with remove (), so here is the answer about destroy ().

Destruction methods (sometimes called dispose) are common in many programming languages ​​to clear the resources used by an instance of something. Destruction conditionally represents the concept of pure memory (i.e., non-visual). The destroy method often differs from the object-oriented method of the destructor in terms of lifetime in that for destruction it is implied that it can be explicitly called by the programmer to clear the memory and resources before starting the final destructor or before collecting the garbage collector (in any case earlier, that you can release material when you no longer need it, instead of allowing these resources to be used until the end of the program). Sometimes the destructor method naturally contains a call to the destroy method to ensure that all resources are finally cleaned up, so usually the programmer does not have to worry about not calling it because it will eventually be called automatically.

Often the body of the destruction method code is provided by the programmer for the behavior of the application (redefined from the base class / object in some languages). This means that calling destroy without providing an implementation for it often does nothing - the empty body of the code. Of course, for TinyMCE he will implement his own destruction methods accordingly.

The TinyMCE documentation does not promise any visual changes upon destruction, only if the instance is deprived of the possibility of a memory leak. This is consistent with what destruction methods usually do.

Destroys an instance of the editor, deleting all events, link elements, or other resources that may be leaked. This method will be automatically called when the page is unloaded, but you can also call it directly if you know what you are doing.

That's why TinyMCE provides a remove () method to visually change things, because destroy () is not designed to accomplish the same purpose.

To completely destroy TinyMCE, you can perform removal () for visual cleaning, and then dispose () for cleaning memory; however, these methods are implementation specific, and I'm not sure how TinyMCE will react.

+7
source share

hi my problem is solved with this

Switch one or more TinyMCE instances using:

$ ('editors.') TinyMCE ('toggle switch') ;.

Or completely remove instances using:

$ ('editors.') TinyMCE ('delete') ;.

from http://mktgdept.com/jquery-tinymce-plugin

+1
source share

To "destroy" an element in jquery, use $(node).remove() . If this does not work, the sample code will help us better understand / answer your question.

0
source share

All Articles