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

Adding editors dynamically.

Support forum for WYMeditor.

Adding editors dynamically.

Postby karlmdavis on Mon Sep 24, 2007 12:20 am

Hello all,

I'm putting together a page to which editor fields (textarea elements) are added dynamically (via AJAX) in response to user input. WYMeditor seems to have problems if I call its init code more than once on the page (e.g., the second time an editor is added).

I would guess this has something to do with WYMeditor not checking to see if page elements have already been converted to WYMeditors when the Wymeditor constructor is called.

As a workaround, I would be more than happy to de-WYMeditor-ize all of my textfields when a new one is added, and then re-WYMeditor-ize all of them, but there doesn't seem to be any functionality to do that in the WYMeditor API.

Can anyone offer a solution?
karlmdavis
 
Posts: 3
Joined: Sun Sep 23, 2007 6:41 pm

Postby jfh on Wed Sep 26, 2007 12:14 pm

Interesting problem :)
What error do you get?
Could you please create a feature request on the Trac and attach your test page? Thanks.
User avatar
jfh
Site Admin
 
Posts: 370
Joined: Sat Sep 23, 2006 8:43 pm
Location: Belgium

Postby PACE on Fri Oct 12, 2007 10:35 am

Hi, I'm trying something similar. I want to add "instant-edit" to my CMS, so when the user clicks double on an editable div, this div is converted to a WYMeditor. By clicking the save button or clicking outside the editor, the content is either saved (via ajax to the server) or the process is canceled as a whole, and the editor should revert to the div either with the new content or with the old.

But, I have not found the opposite of .wymeditor() to deinitialize the div. I've removed the editor-div via jQuery and made the original div visible again, and it works, but isn't there a cleaner solution for this?

Have not tried yet with multiple instances but I'm planning on that too!

br,
Benjamin
PACE
 
Posts: 15
Joined: Fri Oct 12, 2007 10:24 am
Location: Austria

Postby paperogiallo on Thu Oct 18, 2007 8:37 am

I guess we all work on the same topic in the same time... :)

So, this msg is just to say that I agree on that future versions of Wym should provide some cleaner way to add and remove WYMfied textarea, like TinyMCE's "MCEAddControl" and "MCERemoveControl".

Another time, thanks developers for their huge work! WYM is THE editor, the only editor I will use for my next projects.
paperogiallo
 
Posts: 6
Joined: Tue Oct 09, 2007 1:15 pm

Postby rtomlinson on Mon Oct 22, 2007 9:58 pm

I'm also working on the ability to dynamically change the number of editors on the page, and I am also having issues with not being able to remove prior controls. It actually causes the page to hang after the 3rd or 4th modification.

I've got a test page here.

On the page, there are two templates: a basic single content box, and a 4 square grid. You can switch between the two by clicking the respective icon, and it will reload the content areas via AJAX. It passes along any changes to the content along as well, so that it will still be there if you change your mind and switch back. (Edit: fixed the other issue, so removed the reference to it)

My problem as it relates to this thread is that without being able to free the controls, it keeps adding more, and then hangs.
rtomlinson
 
Posts: 4
Joined: Fri Oct 19, 2007 11:33 pm

Postby rtomlinson on Mon Oct 22, 2007 10:27 pm

Well, I figured this out too (for my condition, anyway).

After updating, I added the following two lines before loading the new textareas:

Code: Select all
WYM_INSTANCES = null;
WYM_INSTANCES = new Array();


For those only wanting to remove a single element, you might try:

Code: Select all
WYM_INSTANCES[i] = null;
WYM_INSTANCES.splice(i, 1);
rtomlinson
 
Posts: 4
Joined: Fri Oct 19, 2007 11:33 pm


Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests