views:

164

answers:

1

Hi everybody,

I'm trying tu use Jeditable to edit inline some content put in textareas. So, I call the script files:

<script src="js/jquery.jeditable.js"></script>
<script src="js/jquery.jeditable.autogrow.js"></script>
<script src="js/jquery.autogrow.js"></script>

Then I have a function that sould send data to the server (I kept the example URL). This fonction creates a textarea and permits the edition:

$(".autogrow").editable("http://www.appelsiini.net/projects/jeditable/php/save.php", { 
 indicator : "<img src='img/indicator.gif'>",
 type      : "autogrow",
 submit    : 'OK',
 cancel    : 'cancel',
 tooltip   : "Click to edit...",
 onblur    : "ignore",
 event   : "dblclick",
 autogrow : {
  lineHeight : 16,
  minHeight  : 32
 }
});

Then, I have the data to edit thant contains html tags because I have to store them:

$data = '<div style="color:red">Foo Bar</div>';
echo '<div class="autogrow">'.htmlentities($data).'</div>';

The "echo" displays the "$data" content perfectly with the tags, but when I want to edit inline the DIV, a textarea is created and the following data is displayed in that textarea:

&lt;div style="color:red"&gt;Foo Bar&lt;div&gt;

instead of:

<div style="color:red">Foo Bar</div>

How can I display the right characters?

Thank you very much,

regards

A: 

Edit: I didn't realise this question was asked over 2 months ago - Sorry

Have you tried using the html_entity_decode() function when you put the text into a text area?

The htmlentities() function will change things like < into &lt;, while html_entity_decode() should change &lt; into <

Basically a textarea will not format your HTML tags so you need to convert them yourself.

However it has been a while since I used PHP so I can't remember too well.

Sour Lemon