cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

surroundContents() and losing track changes

samah
1-Newbie

surroundContents() and losing track changes

Hello Adepters,


I wrote a function to wrap/unwrap a range in a special element. To wrap the range I use the range function range.surroundContents(element). To unwrap an element I replace the wrapped range by the actual range. Now in the function if I don’t turn track changes off the whole range is marked as added which I don’t want. If in the wrap/unwrap function I turn track changes off I lose all track changes I had in the actual range.



How do I wrap/unwrap a range in anew element without losing track changes?



Thanks,


-Samah

2 REPLIES 2

Hi Samah-



The AOM functions for modifying a range do seem to spread the change
tracking markup around more than one might like. To get around this, you
can try "cheating" and using the Acl object to apply ACL functions,
which give simpler change tracking markup. For example, instead of using
range.surroundContents(), make the range selected and then call
Acl.execute("insert_tag {tagname}"). This will leave the existing
content alone, and will only mark the tag insertion as a change. For
removing a wrapper, position the caret at the beginning of the element
(just inside the start tag) and use Acl.execute("delete_tag").



--Clay



Clay Helberg

Senior Consultant

TerraXML


samah
1-Newbie
(To:samah)

Hi Clay,

Thanks for your reply. The insert_tag() & delete_tag() worked perfectly.

-Samah
Top Tags