Forum closed. New forum available at

Creating clones / new instances on the fly

Support forum for WYMeditor.

Creating clones / new instances on the fly

Postby grokcore on Fri Feb 29, 2008 6:49 pm

What I'm looking for is to be able to create mutliple instances on the fly.
Basically my CMS is to have repeatable regions, which can be created or removed per page.

So I have a fieldset with all editable regions within it, this fieldset gets cloned and inserted (after the last fieldset). The attributes of any inputs / textareas get re-written with the next increment ID (based on their position in the parent fieldset that the child fieldset with these inputs resides)

This method works well and I can process all the data accordingly (all stored in MySQL in a format that can allow me to easily recreate the data as XML)

Now the real issue is of course, when I clone wymEditor, it's not going to pan out very well. To the DOM it's a perfect clone and functionally the editor works fine. However when saving, it's not going to grab any information as any fields & elements relating to the new instance are 'bad' clones (and are really breaking the rules of the doc type e.g. duplicate ID's)

I basically need to
1) increment the # of instances of wym (removing instances doesn't seem to be a problem, although I suppose it could)
2) clear the content in the new instance
3) fix the attributes of the new instance

What I would -really- appreciate is a few pointers to get me started, what should I be looking for and what I should avoid.

Many thanks in advance

Never underestimate the power of human stupidity.
Robert A. Heinlein
Posts: 3
Joined: Fri Feb 29, 2008 7:48 am

my Solution

Postby grokcore on Fri Feb 29, 2008 7:28 pm

After some playing around.. I see that it's probably a lot easier then I anticipated.

so for at the initial page load:
Code: Select all

To initialize and then to prevent wym from re-wyming it self

then -before- the actual insert in my click event
Code: Select all

and now after some processing we finally insert it back into the DOM

Code: Select all

Seems to work just fine now. The new instance gets registered properly.
Posts: 3
Joined: Fri Feb 29, 2008 7:48 am

Return to Support

Who is online

Users browsing this forum: No registered users and 2 guests