Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2006-07-25 22:25:19

Dortamur
New member
Registered: 2005-06-08
Posts: 7

Manipulating the DOM of editable code

Is it possible to reference the HTML via Javascript/DOM techniques, while in the editor? (And if so, how?)

I have a page template where certain content is dynamically generated via JS based on the content of other sections of the page (think like a Spreadsheet). While this works fine when displaying the HTML normally, editing the chunk doesn't get the calculated regions evaluated, so it always saves without these filled in. I'd prefer if the calculations could be performed on the editable version (on load and/or on save), and saved as "defaults". Heck, if they updated and saved properly, I wouldn't need to do the DOM manipulation on the normal presented copy (assuming no dynamic content from other sources affects the calculations).

Offline

#2 2006-07-26 00:03:02

Dortamur
New member
Registered: 2005-06-08
Posts: 7

Re: Manipulating the DOM of editable code

Ok, I've nutted this one out. If I find the iframe object, grab the document object from that, I can then use that as a reference for finding and manipulating objects under that DOM.

ie;

Where "edframe" is the iframe object:
   var doc = edframe.contentDocument || edframe.contentWindow.document;

Then you can use doc.getElementById(), etc...

(contentDocument works in Firefox, contentWindow.document in IE.)

Offline

#3 2006-07-26 05:38:55

ray
Xinha Administrator
From: Germany
Registered: 2005-03-23
Posts: 521
Website

Re: Manipulating the DOM of editable code

You can also access the content document as a property of the xinha object via

xinha_editors.youreditor._doc

This is basically the same as you wrote, but you don't have to dig after the iframe object itself

Last edited by ray (2006-07-26 05:42:40)

Offline

Board footer

Powered by FluxBB