When the user logs in, and is taken to the main page - that user might have multiple redactor editors on his page.
Since I'm generating the page on the server I want to populate each of editors with data the user had saved earlier.
Hence, the question is :
How do I populate these editors from server side itself ?
I tried to set the value attribute of the textarea, but that didn't work.
My php code is simple :
<?php
echo '<textarea id="editor_" ' + $user_id + ' class='editor' value="'+$savedContent+'"></textarea>';
?>
My javascript code is pretty simple :
$(document).ready(function(){
$(".editor").redactor();
});
Hence when the page is loaded, all the textareas with "editor" as a class turn into redactor editors.
As you see above, each of the editors has a unique "user_id" attached to them.
In my php how should I generate the textarea, so when the javascript runs, all of them are populated.
Not especially aware of Redactor
, but maybe just place the content inside the <textarea>
, as the <textarea>
works differently than a text <input>
:
<?php echo "<textarea id='editor_$user_id' class='editor'>$savedContent</textarea>"; ?>