views:

343

answers:

2

Hello,

I'm using the Scriptaculous Ajax.InPlaceEditor to edit data from my database.

Actually, it works perfectly at first, when there is no data in the database ; Here is what I have in my navigator source code :

<p id="edit" title="Click to edit" >
New text to edit here
</p>

I can create a new record, automaticly add some HTML to change design, and change again and again with no problem thanks to the Ajax.InPlaceEditor. At this time, here is how looks the source code :

<p id="edit" title="Click to edit" >
<ol>
<li>item1</li>
<li>item2</li>
</ol>
</p>

Ok, this is just perfect. And this is perfect too in the database...

But if I reload the full page, then the initial value of the editable paragraph is now HTML coming straight from the database, and here is what I have in the source code :

<p id="edit" title="Click to edit"/>
<ol>
<li>item1</li>
<li>item2</li>
</ol>

As you can see, the < / p > is mysterously missing, and the paragraph is not editable any more... Rich noticed that the paragraph was actually self closing... I also tried to manually set HTML text into the database, and the result is the same : < / p > is missing...

Would you have any idea of what's going on, and how to fix it ?

Thank you so much..

+1  A: 

Assuming you copied the HTML correctly, the p tag at the end of the original HTML block is superfluous, since you have closed the p tag in the first block with the slash:

<p id="edit" title="Click to edit"/>
                                  ^closes the p tag

I assume the editor "fixes" HTML so removed the final closing p tag since the p tag was closed before the ordered list begins

Rich
Thanks, I didn't notice that.But in fact I copied the source code with mistakes. I just edited the code. So the question is, why does the P closes before the HTML content ?
Yako
As a test, is it possible to convert the enclosing P to a DIV? I'm curious to see if the same thing happens if the initial HTML is:<DIV id="edit" title="Click to edit" ><ol><li>item1</li><li>item2</li></ol></DIV>
Rich
It may also be helpful to see the javascript code that sets up the editor.
Rich
It's working quite well with a DIV. There is just extra line-jump and an extra tab at the beginning of the textarea. I guess I could find a way to get rid of these details.So thank you, as this is a working solution... But the still, there's a mystery with the P...
Yako
The Javascript is quite common : new Ajax.InPlaceEditor('edit', 'myURL.php', {paramName:'edit',cancelControl:'button',cancelText:'Annuler',cols:'60',rows:'8',savingText:'Enregistrement en cours...',onComplete:function(){Rld("obsframe");}}); the onComplete function reloads a printing version iframe..
Yako
Perhaps you should submit this anomaly to the people that maintain the ajax.inplaceeditor. I only suggested using a <DIV> due to experience with other in place editors and how they sometimes strangely modified HTML.
Rich
+1  A: 

You can't wrap ols in ps. That is, the <ol> closes the p earlier than you think. I suggest using a div intsead.

Ms2ger
Yes, thank you. That's finally the solution I used according to the clues from Rich...
Yako