Summary: What I'm trying to ask - are we going about this the completely wrong way, or, is there a way to stop Sharepoint, or its rich editor, from munging the HTML which gets added?
I've been 'dropped' into a project revolving around Sharepoint 2007 (trust me, I'm not entirely pleased about it), and one of the things that is sought after is a way to use a rich-content-area for the users to put in 'rich content' and then add certain 'extras' to the content, such as expandable content areas, dialogs etc.
The initial plan of attack was to add in a custom button to the Sharepoint rich content editor toolbar, which we have code to do this, and it works etc, and attach javascript event handlers to certain elements - which also works - to a point.
One thing we are doing is using an <a>
element and a subsequent <div>
to setup a dialog (using jQuery UI to do the magic). When the user clicks the 'insert dialog' button the following is inserted into the editor:
<a href="#" class="dialog-trigger">Click me to open the dialog</a>
<div class="dialog-content">
this is some dialog content etc
</div>
When the page loads we hook onto the .dialog-trigger click method, grab the a
element's sibling which is a .dialog-content
and set that up as a dialog. This 'works' as long as you don't want to edit anything.
What I have found is that as soon as you start editing the content within the .dialog-content
DIV the rich-content editor starts munging the HTML, for example, adding a list adds in the following HTML:
<li><div class=dialog-content>Some list item</div></li>
<li><div class=dialog-content>Some list item 2</div></li>
<li><div class=dialog-content>Another list item</div></li>
As you can imagine, this kind of breaks what we are trying to do.
To summarize what I'm trying to ask - are we going about this the completely wrong way, or, is there a way to stop Sharepoint, or its rich editor, from munging the HTML which gets added?