Forum closed. New forum available at http://community.wymeditor.org/

How to destroy editor, not just hide?

Support forum for WYMeditor.

How to destroy editor, not just hide?

Postby tkambler on Mon May 04, 2009 6:48 pm

I have an application that's heavy on Ajax... Multiple instances of Wymeditor are created on the page, but after the initial "submit," each submit always pulls data from the first Wymeditor that was created on the page. I've seen posts in the forum about how to hide the editor (turn on, off)... but is there a way to destroy the editor? As in, remove it completely from the DOM? Something like...

$.wymeditors(0).destroy();

Thank you for your input!

Tim
tkambler
 
Posts: 2
Joined: Mon May 04, 2009 6:45 pm

Re: How to destroy editor, not just hide?

Postby mr_lundis on Wed Jun 03, 2009 6:55 pm

Hi!
Edit: Take a look at jfh's example below. Another option could be to repopulate the same editor with new content instead of creating new instances (doing so would also avoid the cost of reinitializing the editor which is relatively expensive.)

Cheers! ;)
Jonatan Lundin - designer, developer and forum moderator. You should follow me on Twitter!
mr_lundis
 
Posts: 335
Joined: Sun Dec 02, 2007 10:59 am
Location: Sweden

Re: How to destroy editor, not just hide?

Postby jfh on Fri Jun 05, 2009 8:43 pm

Following code should help, calling update() and removing WYMeditor instances from the DOM and the instances array:
Code: Select all
jQuery.each(WYMeditor.INSTANCES, function() {
      this.update();
      $(this._box).remove();
      $(this._element).show();
      delete this;
});
User avatar
jfh
Site Admin
 
Posts: 370
Joined: Sat Sep 23, 2006 8:43 pm
Location: Belgium


Return to Support

Who is online

Users browsing this forum: No registered users and 4 guests