Have a slight problem with TinyMCE.
I have a foreach loop and the first instance that this is run the tags show as tinymce. However, the second loop of this foreach and the tinymce is not visible. THe only thing that shows is a html textarea.
I think it's to do with the id of the textareas and how tinymce implement their textareas. So I think the next time the loop happens the Id's have to different to the previous ones.
Am I right in thinking this? If so, how do I go about fixing this?
Below is the code I'm using.
<table width="90%">
<thead>
<th align="left">Title</th>
<th align="left">Sub Title</th>
<th align="left">Story</th>
</thead>
<?php
$rowSet = $db->selectAllNoLimitFootball("news");
foreach($rowSet as $key => $news){
$id = $news['id']; //Assign the id of the array instance to a variable to use on the button below
echo "<tr>";
echo "<td><textarea id=\"title2\" name=\"title\">".$news['title']."</textarea></td>";
echo "<td><textarea id=\"subtitle2\" name=\"subtitle\">".$news['subtitle']."</textarea></td>";
echo "<td><textarea id=\"story2\" name=\"story\">".$news['story']."</textarea></td>";
echo "<tr><td><br>Live: <input type=\"checkbox\" name=\"live\" id=\"live\" value=\"1\"><br><br></td></tr>";
echo "</tr>";
echo "<tr><td colspan=\"3\"><br><button class=\"submit\" name=\"remove-news-id\" value=\"$id\">Delete</button>
<button class=\"submit\" name=\"update-news-id\" value=\"$id\">Update</button></td></tr>";
echo "<tr><td colspan=\"3\"><hr></td></tr>";
}
?>
</table>
Below is the javascript.
tinymce.init({
selector: "textarea",
plugins: [
"advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"table contextmenu directionality emoticons template textcolor paste fullpage textcolor"
],
toolbar1: "newdocument fullpage | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | styleselect formatselect fontselect fontsizeselect",
toolbar2: "cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor image media code | inserttime preview | forecolor backcolor",
toolbar3: "table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft",
menubar: false,
toolbar_items_size: 'small',
style_formats: [
{title: 'Bold text', inline: 'b'},
{title: 'Red text', inline: 'span', styles: {color: '#ff0000'}},
{title: 'Red header', block: 'h1', styles: {color: '#ff0000'}},
{title: 'Example 1', inline: 'span', classes: 'example1'},
{title: 'Example 2', inline: 'span', classes: 'example2'},
{title: 'Table styles'},
{title: 'Table row 1', selector: 'tr', classes: 'tablerow1'}
]
});